Skip to content
Justice Tech School

Objects and JSON

Objects hold data. JSON.stringify and parse convert to text and back.

Example
const user = { name: "Ada", skills: ["js", "node"] };
const text = JSON.stringify(user);
console.log(text);
console.log(JSON.parse(text).skills[1]);
console.log(JSON.stringify(user, null, 2));

Result

{"name":"Ada","skills":["js","node"]}
node
{
  "name": "Ada",
  "skills": [
    "js",
    "node"
  ]
}

Exercise

Object to text.

JSON.(obj)

Quiz Test

What does parse return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.