JSON Module #28 Flashcards
What types of data does JSON support?
Number: any number that’s not wrapped in quotes
String: any set of characters wrapped in quotes
Boolean: true or false
Array: a list of values, wrapped in square brackets
Object: a set of key-value pairs, wrapped in curly brackets
null: the null word, which represents an empty value
Any other data type that’s more complex than this must
be serialized to a string (and then de-serialized) in order to be stored in JSON.
Which method will return an object that contains the parsed JSON
JSON.parse takes a JSON string as its parameter, and returns an object that contains the parsed JSON:
What does JSON.stringify( ) do?
JSON.stringify() takes a JavaScript object as its parameter, and returns a string that represents it in JSON:
Which second argument does JSON accept
The reviver function: You can use that to customize the JSON parsing and perform any custom operation:
JSON.parse(string, (key, value) => { if (key === "name") { return `The name is ${value}` } else { return value } })