Back

JSON format

JSON (JavaScript Object Notation) is the standard format APIs use to send data. It looks like a JS object, but keys must use double quotes and it can't hold functions. JSON.stringify turns an object into a JSON string; JSON.parse turns it back.

{
  "id": 1,
  "name": "Daniel",
  "isStudent": true,
  "skills": ["React", "Node"],
  "address": { "city": "Dallas" },
  "phone": null
}

const user = { name: "Daniel", age: 20 }
const text = JSON.stringify(user)   // '{"name":"Daniel","age":20}'
const back = JSON.parse(text)       // object again

Roadmap