1 | # Structured JSON
|
2 |
|
3 | Stringify and parse JavaScript values according to Structured Clone Algorithm.
|
4 |
|
5 | This allows sending more advanced JS types across the network, including `Date`, `Map`, `Set`, `ArrayBuffer` and various typed arrays.
|
6 |
|
7 | See <https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm> for more.
|
8 |
|
9 | ## Usage
|
10 | ```js
|
11 | import * as Structured from '@worker-tools/structured-json'
|
12 | ```
|
13 |
|
14 | The module exposes these functions:
|
15 | - `Structured.stringify`
|
16 | - `Structured.parse`
|
17 | - `Structured.toJSON`
|
18 | - `Structured.fromJSON`
|
19 |
|
20 | This module supports `File`, `Blob` and `FileList`, however use of `stringifyAsync` or `toJSONAsync` is required if your data contains any of these.
|
21 |
|
22 | <br/>
|
23 |
|
24 | --------
|
25 |
|
26 | <br/>
|
27 |
|
28 | <p align="center"><a href="https://workers.tools"><img src="https://workers.tools/assets/img/logo.svg" width="100" height="100" /></a>
|
29 | <p align="center">This module is part of the Worker Tools collection<br/>β
|
30 |
|
31 | [Worker Tools](https://workers.tools) are a collection of TypeScript libraries for writing web servers in [Worker Runtimes](https://workers.js.org) such as Cloudflare Workers, Deno Deploy and Service Workers in the browser.
|
32 |
|
33 | If you liked this module, you might also like:
|
34 |
|
35 | - π§ [__Worker Router__][router] --- Complete routing solution that works across CF Workers, Deno and Service Workers
|
36 | - π [__Worker Middleware__][middleware] --- A suite of standalone HTTP server-side middleware with TypeScript support
|
37 | - π [__Worker HTML__][html] --- HTML templating and streaming response library
|
38 | - π¦ [__Storage Area__][kv-storage] --- Key-value store abstraction across [Cloudflare KV][cloudflare-kv-storage], [Deno][deno-kv-storage] and browsers.
|
39 | - π [__Response Creators__][response-creators] --- Factory functions for responses with pre-filled status and status text
|
40 | - π [__Stream Response__][stream-response] --- Use async generators to build streaming responses for SSE, etc...
|
41 | - π₯ [__JSON Fetch__][json-fetch] --- Drop-in replacements for Fetch API classes with first class support for JSON.
|
42 | - π¦ [__JSON Stream__][json-stream] --- Streaming JSON parser/stingifier with first class support for web streams.
|
43 |
|
44 | Worker Tools also includes a number of polyfills that help bridge the gap between Worker Runtimes:
|
45 | - βοΈ [__HTML Rewriter__][html-rewriter] --- Cloudflare's HTML Rewriter for use in Deno, browsers, etc...
|
46 | - π [__Location Polyfill__][location-polyfill] --- A `Location` polyfill for Cloudflare Workers.
|
47 | - π¦ [__Deno Fetch Event Adapter__][deno-fetch-event-adapter] --- Dispatches global `fetch` events using Denoβs native HTTP server.
|
48 |
|
49 | [router]: https://workers.tools/router
|
50 | [middleware]: https://workers.tools/middleware
|
51 | [html]: https://workers.tools/html
|
52 | [kv-storage]: https://workers.tools/kv-storage
|
53 | [cloudflare-kv-storage]: https://workers.tools/cloudflare-kv-storage
|
54 | [deno-kv-storage]: https://workers.tools/deno-kv-storage
|
55 | [kv-storage-polyfill]: https://workers.tools/kv-storage-polyfill
|
56 | [response-creators]: https://workers.tools/response-creators
|
57 | [stream-response]: https://workers.tools/stream-response
|
58 | [json-fetch]: https://workers.tools/json-fetch
|
59 | [json-stream]: https://workers.tools/json-stream
|
60 | [request-cookie-store]: https://workers.tools/request-cookie-store
|
61 | [extendable-promise]: https://workers.tools/extendable-promise
|
62 | [html-rewriter]: https://workers.tools/html-rewriter
|
63 | [location-polyfill]: https://workers.tools/location-polyfill
|
64 | [deno-fetch-event-adapter]: https://workers.tools/deno-fetch-event-adapter
|
65 |
|
66 | Fore more visit [workers.tools](https://workers.tools).
|