| [ Web Proxy ] |
| Viewing: https://codablejson.com/docs/json-serialization | [Back] [Original] |
CodableJSON provides high-performance JSON serialization that extends standard JSON to handle JavaScript types that JSON cant serialize natively.
import { encode, decode } from "codablejson";
const data = {
date: new Date("2025-01-01"),
set: new Set(["a", "b", "c"]),
map: new Map([["key", "value"]]),
};
const encoded = encode(data);
// Result: {
// date: { $$Date: "2025-01-01T00:00:00.000Z" },
// set: { $$Set: ["a", "b", "c"] },
// map: { $$Map: [["key", "value"]] }
// }
const decoded = decode(encoded);
// decoded.date instanceof Date === trueOpen playground to test your own data.
Date, BigInt, Map, Set, RegExp, Symbol, Error, URL, typed arrays, and moreFor convenience, CodableJSON provides stringify and parse functions that combine encoding/decoding with JSON stringification:
import { stringify, parse } from "codablejson";
const jsonString = stringify(data);
const restored = parse(jsonString);Experiment with CodableJSON in the playground to see how different types are encoded and test circular reference handling.
| Web Proxy Viewer | New URL | Original Page |