JSON Flashcards

1
Q

What is JSON?

A

JS object notation

used to send data btwn computer systems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are serialization and deserialization?

A

serialization: converting an Object into stream of bytes so that it can be transferred over a network or stored in a persistent storage.
deserialization: Fetch a stream of bytes from network or persistence storage and convert it back to the Object with the same state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why are serialization and deserialization useful?

A

pack up and send data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you serialize a data structure into a JSON string using JavaScript?

A

JSON.stringify(objectName);

must stringify to send as JSON

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you deserialize a JSON string into a data structure using JavaScript?

A

JSON.parse(stringName);

must parse to use in JS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to you store data in localStorage?

A

localStorage.setItem( ‘key’, ‘value’ )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to you retrieve data from localStorage?

A

localStorage.getItem ( ‘key’ );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What data type can localStorage save in the browser?

A

JSON only - string data for keys and values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When does the ‘beforeunload’ event fire on the window object?

A

before window, document, etc are about to be unloaded. document is visible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly