JavaScript Quiz: JSON
How to serialize an object into a JSON string?
let person = { "firstName" : "Alice", "lastName" : "Jones" }; console.log(person); /* output: { firstName: 'Alice', lastName: 'Jones' } */ let personString = JSON.stringify(person); console.log(personString); /* output: {"firstName":"Alice","lastName":"Jones"} */
How to deserialize a JSON string into an object?
let personParsed = JSON.parse(personString);