javascript-and-json Flashcards
What is JSON?
JSON stands for JavaScript Object Notation and it is a file type .json which holds object literals, array literals, numbers, and strings which can be stringified or parsed in JavaScript.
What are serialization and deserialization?
Serialization is the process of turning an object into bytes so that it can be easily transferred. Deserialization is taking those bytes and converting them to a native object.
Why are serialization and deserialization useful?
Serialization and deserialization allow easy transportation of data between different files, systems, and coding languages. Strings are a part of all coding languages but JS objects and arrays are much more specific and are storages in memory. Strings are easily converted.
How do you serialize a data structure into a JSON string using JavaScript?
To serialize a data structure in JavaScript into a JSON string, use JSON.stringify(JavaScript native object) which will turn the native object into a JSON string.
How do you deserialize a JSON string into a data structure using JavaScript?
To deserialize a JSON string into a data structure using JavaScript you use the command JSON.parse(json string) which turns the JSON string into a native JavaScript object.