JSON – stringify and parse, online

Six activities your students do on their own devices. See who's finished, and their scores.

JSON – stringify and parse in one minute

What students need to know

This is exactly what the stringify() method does. stringify() turns an object or array into a JSON-formatted string.

JavaScript requires all capitals: JSON.stringify(). JavaScript is case-sensitive, so 'stringify' must be lowercase.

Mistakes students make

  • 'JSON' must be capitalized - it's not 'json'.
  • 'stringify' must be lowercase - a capital S causes an error.
  • 'parse' must be lowercase - a capital P causes an error.
  • 'JSON' must be all uppercase, not 'Json'.
PREVIOUS · MODULE 45throw Statement
YOU ARE HERE · MODULE 46JSON – stringify and parse
NEXT · MODULE 47OOP – Classes & Objects

Discover other journeys with this module

What students will learn in this module

Every question in Module 46

Quick questions

  1. Does JSON.stringify() convert a JS value into a JSON string?ANoBYes
  2. Does JSON.parse() convert a JSON string into a JS value?ANoBYes
  3. Is 'json' with a lowercase j valid for JSON.stringify()?ANoBYes
  4. Must 'stringify' be written in lowercase?AYesBNo
  5. Must 'parse' be written in lowercase?AYesBNo

Key terms

Students type the meaning of:

  • JSON.stringify()

Match the pairs

JSON.stringify(person)Match it to what it does
JSON.parse(json)Match it to what it does
Converts a JS value into a JSON-formatted stringMatch it to what it does
Converts a JSON string into a usable JS valueMatch it to what it does
let j = json.stringify(obj);Match it to what it does
let o = JSON.Parse(text);Match it to what it does

Fill in the blanks

  1. let json = JSON._________(person);

    Hint: Type the method that converts a value into a JSON string.

  2. let obj = JSON._____(json);

    Hint: Type the method that converts a JSON string back into a value.

  3. let text = JSON._________(data);

    Hint: Type the method that converts a value into a JSON string.

  4. let result = JSON._____(text);

    Hint: Type the method that converts a JSON string back into a value.

  5. let data2 = JSON._________({a: 1});

    Hint: Type the method that converts a value into a JSON string.

Spot the error

Question 1

Alet j = json.parse(s);Blet s = '{"a":1}';Cconsole.log(j);

Question 2

Alet t = {b: 2};Blet j = JSON.Stringify(t);Cconsole.log(j);

Question 3

Alet u = {c: 3};Blet j2 = JSON.stringify(u);Clet k = JSON.Parse(j2);

Question 4

Alet m = Json.stringify(x);Blet x = {d: 4};Cconsole.log(m);

Question 5

Alet y = {e: 5};Blet n = JSON.stringfy(y);Cconsole.log(n);