JSON MCQs – Tools and Debugging

11.) How do you identify invalid JSON in a web application?

A) Use a linter or formatter tool
B) Use the browser’s developer tools
C) Log errors in the console
D) All of the above

Answer: Option D

Explanation: Tools like linters, developer consoles, and logging can help identify invalid JSON.

12.) Which of the following methods can help trace JSON parsing errors in JavaScript?

A) console.parse()
B) try…catch blocks around JSON.parse()
C) JSON.log()
D) window.debug()

Answer: Option B

Explanation: Wrapping JSON.parse() in a try…catch block allows you to handle parsing errors effectively.

13.) What does a JSON path debugger do?

A) Beautifies JSON
B) Validates JSON syntax
C) Extracts specific values from JSON
D) Converts JSON to CSV

Answer: Option C

Explanation: JSON path debuggers extract and manipulate specific data points from JSON structures.

14.) Which tool can convert a JSON file into a different format like CSV?

A) jq
B) JSONLint
C) Postman
D) JSON Formatter

Answer: Option A

Explanation: The jq command-line tool can transform JSON data into formats like CSV.

15.) What is the primary function of JSON.stringify(value, replacer, space)?

A) Beautifies JSON output
B) Compresses JSON output
C) Converts JSON to XML
D) Converts an object to a string with formatting options

Answer: Option D

Explanation: The space parameter in JSON.stringify adds indentation to the output string for readability.

16.) How can you identify unused keys in a JSON object?

A) JSONLint
B) Static analysis tools or manual comparison
C) Postman
D) JSON Formatter

Answer: Option B

Explanation: Static analysis tools or manual inspection can help identify unused keys in JSON objects.

17.) How can you debug a failing JSON API request in a browser?

A) Check the network tab in developer tools
B) Use console.log for JSON output
C) Validate the response JSON using a linter
D) All of the above

Answer: Option D

Explanation: : Debugging JSON API requests involves multiple approaches, including using the network tab, logging, and validation tools.

18.) What is the result of running JSON.parse(‘{“key”:value}’) in JavaScript?

A) A key-value pair object
B) null
C) SyntaxError: Unexpected identifier
D) ReferenceError

Answer: Option C

Explanation: JSON keys and values must be wrapped in double quotes. The missing quotes around value result in a syntax error.

Leave a Reply

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