mozilla Flashcards
What is JSON?
A text-based data format following JavaScript object syntax. A standard text-based format for representing structured data based on JavaScript object syntax.
Who was JSON popularized by?
Douglas Crockford.
What does JSON stand for?
JavaScript Object Notation.
What is JSON commonly used for?
Transmitting data in web applications.
Give an example of how JSON can be used to transmit data in web application.
Sending some data from the server to the client, so it can be displayed on a web page, or vice versa
What does the JSON. parse() method do?
Constructs the JavaScript value or object described by the string.
What should you note about JSON even though it closely resembles JavaScript object literal syntax?
It can be used independently from JavaScript, and many programming environments feature the ability to read (parse) and generate JSON.
How does JSON exist?
As a string — useful when you want to transmit data across a network.
What do you need to do if you want to access the JSON data?
Convert it to a native JavaScript object.
Is converting JSON into a JavaScript object difficult?
No, JavaScript provides a global JSON object that has methods available for converting between the two.
What is converting a string to a native object is called?
Deserialization.
What is converting a native object to a string so it can be transmitted across the network is called?
Serialization.
Where can a JSON object be stored?
In its own file, which is basically just a text file with an extension of .json, and a MIME type of application/json.
What data types can you include in JSON?
The same basic data types as you can in a standard JavaScript object — strings, numbers, arrays, booleans, and other object literals.
What’s one way JSON differs from a JavaScript object?
An array is also valid JSON.
Does JSON contain anything other than data?
No, JSON is purely a data format — it contains only properties, no methods.
What is something JSON requires?
Double quotes to be used around strings and property names. Single quotes are not valid.
How can you validate JSON?
Using an application like JSONLint.
Why is it a good idea to validate JSON using an application like JSONLint?
Because even a single misplaced comma or colon can cause a JSON file to go wrong, and not work. You should be careful to validate any data you are attempting to use (although computer-generated JSON is less likely to include errors, as long as the generator program is working correctly).
What other forms can JSON take apart from arrays and objects?
Any data type that is valid for inclusion inside JSON. For example, a single string or number would be a valid JSON object.
In JavaScript code,object properties may be unquoted. How does this differ to JSON?
Only quoted strings may be used as properties in JSON.
What is a way of obtaining JSON?
Use an API called XMLHttpRequest (often called XHR).
What is XMLHttpRequest (often called XHR)?
A very useful JavaScript object that allows us to make network requests to retrieve resources from a server via JavaScript (e.g. images, text, JSON, even HTML snippets).
What advantage is there of making network requests to retrieve resources from a server via JavaScript?
We can update small sections of content without having to reload the entire page.