JSON 1 Flashcards
What is JSON?
JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object, used for transmitting data in web applications.
What are serialization and deserialization?
Serialization is a process of converting an Object into stream of bytes. Deserialization is converting stream of bytes into an object.
Why are serialization and deserialization useful?
Serialization enables us to keep data for use in the running process or other processes if needed. We store the data, then deserialize when it is used elsewhere.
How do you serialize a data structure into a JSON string using JavaScript?
JSON.stringify() method converts a JavaScript object or value to a JSON string
How do you deserialize a JSON string into a data structure using JavaScript?
JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string
How to you store data in localStorage?
setItem() method
How to you retrieve data from localStorage?
getItem() method