JSON MCQ

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?

a) JavaScript Oriented Notation
b) JavaScript Object Notation
c) Java Ordered Notation
d) Java Object Notation

Answer:

b) JavaScript Object Notation

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?

a) Key-Value pairs
b) Metadata
c) Binary Data
d) Key-Object pairs

Answer:

a) Key-Value pairs

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?

A. Data storage
B. Data interchange
C. Data computation
D. Data security

Answer:

B. Data interchange

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?

A. function() { }
B. { key: "value" }
C. 'key': 'value'
D. NaN

Answer:

B. { key: "value" }

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…?

A. Single quotes (' ')
B. Double quotes (" ")
C. Either single or double quotes
D. No quotes

Answer:

B. Double quotes (" ")

Explanation:

In JSON, strings are always enclosed in double quotes.

6. What is the file extension typically used for JSON files?

A. .js
B. .java
C. .json
D. .data

Answer:

C. .json

Explanation:

JSON files typically have a .json file extension.

7. Which of the following data types is not supported in JSON?

A. Arrays
B. Functions
C. Numbers
D. Strings

Answer:

B. Functions

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?

A. "true"
B. true
C. 'true'
D. 01

Answer:

B. true

Explanation:

Booleans in JSON are represented as true or false without quotes.

9. Which data structures can JSON represent?

A. Objects and Arrays
B. Trees
C. Graphs
D. Queues

Answer:

A. Objects and Arrays

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'?

A. undefined
B. none
C. null
D. zero

Answer:

C. null

Explanation:

JSON uses null to represent no value or a null value.

11. How would you represent a numeric value in JSON?

A. "10"
B. 10.0
C. '10'
D. .10

Answer:

B. 10.0

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?

A. { }
B. ( )
C. < >
D. [ ]

Answer:

D. [ ]

Explanation:

Arrays in JSON are enclosed in square brackets [ ].

13. How would you represent a date in JSON?

A. As a Date object
B. As a string
C. As a number
D. As a function

Answer:

B. As a string

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…?

A. Strings
B. Numbers
C. Either strings or numbers
D. Arrays

Answer:

A. Strings

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?

A. { "name": "John", "age": 30, "city": "New York" }
B. { name: "John", age: 30, city: "New York" }
C. { 'name': 'John', 'age': 30, 'city': 'New York' }
D. { name = "John", age = 30, city = "New York" }

Answer:

A. { "name": "John", "age": 30, "city": "New York" }

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"?

A. An object
B. A string
C. An array
D. A function

Answer:

C. An array

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?

A. String
B. Number
C. Object
D. Boolean

Answer:

C. Object

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?

A. {}
B. []
C. ""
D. null

Answer:

A. {}

Explanation:

An empty object in JSON is represented by {}.

19. How can you represent a negative number in JSON?

A. -123
B. "123-"
C. 123-
D. "negative123"

Answer:

A. -123

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?

A. String
B. Object
C. Array
D. Boolean

Answer:

D. Boolean

Explanation:

The value true in JSON represents a boolean data type.

21. What is the root of a JSON document?

A. Always an object
B. Always an array
C. Either an object or an array
D. Neither an object nor an array

Answer:

C. Either an object or an array

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?

A. ;
B. :
C. =
D. ,

Answer:

B. :

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…?

A. Backticks
B. Single quotes
C. Escape sequences
D. Brackets

Answer:

C. Escape sequences

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?

A. JSON.parse()
B. JSON.stringify()
C. JSON.convert()
D. JSON.encode()

Answer:

B. JSON.stringify()

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…?

A. Semicolons ;
B. Commas ,
C. Colons :
D. Spaces

Answer:

B. Commas ,

Explanation:

In a JSON array, values are separated by commas.


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top