QuizzesJSON — Serialising, Parsing and the Sharp Edges — Concept Check
intermediate
javascript

JSON — Serialising, Parsing and the Sharp Edges — Concept Check

Questions on JSON — Serialising, Parsing and the Sharp Edges. JSON.stringify and JSON.parse move data between JavaScript and the wire. What they silently drop — undefined, functions, Dates, Map, Set — is the part worth knowing.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on JSON — Serialising, Parsing and the Sharp Edges — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You serialize an object with a Date using JSON.stringify. What happens to the Date?

    • AIt is removed from the object.
    • BIt is converted to an integer timestamp.
    • CIt becomes an ISO string.
    • DIt becomes null.
  2. 2.When using JSON.stringify on an object with a Map, what is the result?

    • AThe Map is preserved as is.
    • BThe Map is converted to an array of entries.
    • CThe Map becomes an empty object.
    • DThe Map is serialized as a string.
  3. 3.A JSON.parse operation throws an error. What is a likely cause?

    • AThe input is malformed JSON.
    • BThe input includes a BigInt.
    • CThe input has undefined values.
    • DThe input contains a Date object.
  4. 4.You serialize an array with undefined values using JSON.stringify. What happens?

    • AUndefined values become empty strings.
    • BUndefined values are removed.
    • CUndefined values become null.
    • DUndefined values cause an error.
  5. 5.What happens if you try to serialize a BigInt using JSON.stringify?

    • AIt is serialized as a string.
    • BIt throws an error.
    • CIt is converted to a number.
    • DIt becomes null.
  6. 6.A developer uses JSON.stringify with a replacer function. What can this function do?

    • AEnsure undefined values are serialized.
    • BConvert Dates to timestamps.
    • CFilter out sensitive information.
    • DPreserve Map and Set contents.
  7. 7.Why might JSON.stringify([1, undefined, 3]) not behave as expected?

    • AUndefined values are ignored.
    • BUndefined becomes null, not removed.
    • CUndefined values are serialized as 0.
    • DUndefined values cause an error.
  8. 8.What is a safe practice when using JSON.parse with data from an API?

    • AAssume all responses are JSON.
    • BUse a try-catch to handle errors.
    • CParse without validation for speed.
    • DCheck response status before parsing.