JSON MCQs – JSON Syntax and Basics

This post contains top MCQs on “JSON Syntax and Basics” with answers and explanations. These questions are designed to help you strengthen your understanding and prepare for technical interviews effectively.

JSON (JavaScript Object Notation) syntax forms the foundation for working with this popular data format. Knowing the rules of JSON syntax and understanding the basics, such as data types, key-value pairs, and arrays, is essential for software developers. These concepts are critical for handling APIs, configuring applications, and working with databases.

1.) What type of data does a JSON object contain?

A) Only text
B) Key-value pairs
C) Only arrays
D) Only numbers

Answer: Option B

Explanation: JSON objects store data in the form of key-value pairs enclosed in curly braces {}.

2.) Which of the following is NOT valid in JSON?

A) Numbers
B) Boolean values
C) Comments
D) Strings

Answer: Option C

Explanation: JSON does not support comments; it is strictly a data format.

3.) Which of these is NOT true about JSON?

A) JSON is lightweight and language-independent.
B) JSON keys must always be strings.
C) JSON supports single-line and multi-line comments.
D) JSON is commonly used for APIs.

Answer: Option C

Explanation: JSON does not support comments of any kind, which is a deliberate design choice.

4.) What is used to enclose JSON keys?

A) Single quotes
B) Double quotes
C) No quotes
D) Parentheses

Answer: Option B

Explanation: JSON keys must always be enclosed in double quotes.

5.) How are elements in a JSON array separated?

A) Semicolons
B) Commas
C) Colons
D) Dots

Answer: Option B

Explanation: Elements in a JSON array are separated by commas.

6.) Which of the following JSON data types is valid?

A) Float
B) String
C) Object
D) All of the above

Answer: Option D

Explanation: JSON supports data types such as strings, numbers (including floats), objects, arrays, and booleans.

7.) Which of these is NOT a valid JSON value?

A) A function
B) A string
C) A boolean
D) A null value

Answer: Option A

Explanation: JSON does not support functions as values.

8.) What is the correct syntax for a JSON object?

A) {key: “value”}
B) {“key”: “value”}
C) {key = “value”}
D) [key: “value”]

Answer: Option B

Explanation: JSON objects use double quotes for keys and values, separated by a colon.

9.) Which character is used to enclose a JSON array?

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

Answer: Option C

Explanation: JSON arrays are enclosed in square brackets [].

10.) How do you represent a null value in JSON?

A) “null”
B) null
C) NULL
D) (null)

Answer: Option B

Explanation: JSON represents null values with the lowercase keyword null.

Leave a Reply

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