Skip to content
AgileLogics
4 min read

Working with JSON

Prerequisites: Objects

JSON is a text-based data format used constantly for API requests and responses. JavaScript's built-in JSON object converts between JSON text and JavaScript objects/arrays.

const data = { name: "Ada", age: 25 };
const text = JSON.stringify(data);   // object -> JSON string
console.log(text);

const parsed = JSON.parse(text);      // JSON string -> object
console.log(parsed.name);

Expected output

{"name":"Ada","age":25}
Ada

You can check any JSON text for correctness using this site's JSON Formatter while you're building this against a real API.