JSON and Data Shapes
Nested JSON
Read values from a nested JSON shape.
Nested JSON
nested_json.js
const city = "Austin";
const text = "{\"user\":{\"name\":\"Mira\",\"city\":\"" + city + "\"},\"active\":true}";
const name = JSON.parse(text).user.name;
const userCity = JSON.parse(text).user.city;
const active = JSON.parse(text).active;
console.log("name=" + name);
console.log("city=" + userCity);
console.log("active=" + active);
nested-json
JSON can contain objects inside objects. Use one property access per level to reach a nested field.