Loading topic
JSON.stringify does with ordinary data. Unsupported values, replacers, indentation, and toJSON each get their own chapter later.2 min readJSON.parse returns and how JSON text maps onto JavaScript values. Error handling and revivers get their own chapters later.2 min readJSON.stringify turns objects and arrays into text, and how JSON's data types differ from JavaScript's. Here we look at what happens when a value has no direct JSON equivalent.2 min readJSON.parse turns text into values and that you're comfortable with try/catch. The topic here is what happens when the text isn't valid JSON, and how to handle that failure on purpose so it doesn't take down your program.2 min readJSON.stringify serializes objects and arrays, and how it handles values like undefined and functions. The second argument to JSON.stringify is the replacer. It lets you decide which properties appear in the output and what value each one gets. It a2 min readJSON.stringify serializes objects and arrays, and that you have seen its second argument, the replacer. Here we focus on the third argument, space, which controls indentation.2 min readJSON.stringify handles plain objects and unsupported values, and that you have seen a replacer function. It shows how an object can decide for itself what its JSON looks like.2 min readJSON.parse works, why JSON.stringify turns a Date into an ISO string, and how toJSON controls what a class instance writes out. A reviver handles the other direction. It turns the plain strings and objects coming out of JSON back into richer values.2 min readJSON.stringify cannot represent. You will see why cyclic data makes JSON.stringify fail, how to detect that failure, and two ways to serialize such data anyway.2 min readBigInt literals such as 10n, and that you have read the earlier chapters on replacers and revivers. It covers two related problems. JSON.stringify refuses to serialize BigInt values, and JSON.parse silently changes integers t2 min readJSON.stringify handles unsupported values, how JSON.parse builds new objects, and why circular references make stringify throw. It compares two ways to deep-clone data: the classic JSON.parse(JSON.stringify(x)) round trip and the built-in structuredClone.2 min readJSON.parse works, how to catch its SyntaxError, and how a reviver function visits each key/value pair. Here we apply those tools to JSON that comes from outside your program, such as request bodies, webhooks, query strings, files uploaded by users, or th2 min read