JSON (JavaScript Object Notation) has become the de facto standard for data interchange on the web. It’s a lightweight data-interchange format that’s easy for humans to read and write and easy for machines to parse and generate.
This quiz will test your fundamental understanding of JSON. With 25 multiple-choice questions, you’ll cover the basics and dive into some specifics. Let’s see how well you know JSON!
1. What does JSON stand for?
Answer:
Explanation:
JSON stands for JavaScript Object Notation. It is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate.
2. How do you represent data in JSON?
Answer:
Explanation:
In JSON, data is represented as key-value pairs. This means each value is associated with a unique key.
3. Which of the following is the primary purpose of JSON?
Answer:
Explanation:
JSON is mainly used as a format for data interchange between a server and a client or between different parts of an application.
4. Which of these is a valid JSON value?
Answer:
Explanation:
JSON values can be objects, arrays, strings, numbers, true, false, or null. Functions or special numeric values like NaN are not valid.
5. In JSON, strings must be wrapped in…?
Answer:
Explanation:
In JSON, strings are always enclosed in double quotes.
6. What is the file extension typically used for JSON files?
Answer:
Explanation:
JSON files typically have a .json file extension.
7. Which of the following data types is not supported in JSON?
Answer:
Explanation:
JSON does not support functions. It's purely a data format.
8. Which of the following is the correct way to represent a boolean in JSON?
Answer:
Explanation:
Booleans in JSON are represented as true or false without quotes.
9. Which data structures can JSON represent?
Answer:
Explanation:
JSON can represent two structured types: objects (unordered sets of name/value pairs) and arrays (ordered sequences of values).
10. In JSON, which of these values represents 'no value'?
Answer:
Explanation:
JSON uses null to represent no value or a null value.
11. How would you represent a numeric value in JSON?
Answer:
Explanation:
Numeric values in JSON are represented as numbers without quotes. They can be integers or floating-point numbers.
12. Which symbol is used to denote the start and end of an array in JSON?
Answer:
Explanation:
Arrays in JSON are enclosed in square brackets [ ].
13. How would you represent a date in JSON?
Answer:
Explanation:
JSON does not have a date data type. Dates are typically represented as strings.
14. In JSON, the keys of an object must be…?
Answer:
Explanation:
In JSON, the keys of an object must always be strings wrapped in double quotes.
15. Which of the following is a valid JSON object?
Answer:
Explanation:
In JSON, keys must be strings enclosed in double quotes.
16. If you had the following JSON: { "colors": ["red", "green", "blue"] }, how would you describe the value associated with the key "colors"?
Answer:
Explanation:
The value associated with the key "colors" is an array of strings.
17. Which of the following is not a primitive type in JSON?
Answer:
Explanation:
In JSON, the primitive types are string, number, boolean, null. Objects and arrays are considered structured types.
18. How would you represent an empty object in JSON?
Answer:
Explanation:
An empty object in JSON is represented by {}.
19. How can you represent a negative number in JSON?
Answer:
Explanation:
Negative numbers in JSON are represented the same way as in mathematics, with a preceding minus sign.
20. If you encounter a value true in a JSON file, what data type is it?
Answer:
Explanation:
The value true in JSON represents a boolean data type.
21. What is the root of a JSON document?
Answer:
Explanation:
The root of a JSON document can either be an object {} or an array [].
22. Which of the following characters is used to separate key-value pairs in JSON?
Answer:
Explanation:
In JSON, key-value pairs are separated using a colon :.
23. If you wanted to include a special character in a JSON string, you would use…?
Answer:
Explanation:
Special characters in JSON strings are represented using escape sequences, like \" for a double quote.
24. Which of the following methods in JavaScript is used to convert a JavaScript object into a JSON string?
Answer:
Explanation:
The JSON.stringify() method in JavaScript is used to convert a JavaScript object into a JSON string.
25. In a JSON array, values must be separated by…?
Answer:
Explanation:
In a JSON array, values are separated by commas.