Lesson content
Read, practise, then check your understanding
JSON represents objects, arrays, strings, finite numbers, booleans, and null. It has no undefined, BigInt, functions, symbols, comments, dates, references, or cyclic graphs.
Controlled conversion
const value = JSON.parse(text, (key, item) =>
key.endsWith("At") ? new Date(item) : item
);
const output = JSON.stringify(value, ["id", "name"], 2);
Parsing proves syntax, not application validity—validate shapes, sizes, ranges, and allowed keys. Revivers transform bottom-up; replacers select/transform output. Dates normally become strings and BigInt throws unless explicitly converted. Never evaluate JSON as code and place limits on untrusted payload depth and size.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.