350-401 · Question #1290
Which JSON script is properly formatted?
The correct answer is C. {. The properly formatted JSON script starts and ends with curly braces for an object, containing a key-value pair where the value is another object with correctly formatted key-value pairs inside.
Question
Which JSON script is properly formatted?
Options
- A"car":[
- B{
- C{
- D[
How the community answered
(23 responses)- A4% (1)
- C91% (21)
- D4% (1)
Why each option
The properly formatted JSON script starts and ends with curly braces for an object, containing a key-value pair where the value is another object with correctly formatted key-value pairs inside.
This script is improperly formatted because it attempts to define an array following the "car" key, but then lists key-value pairs directly inside the array without enclosing them in curly braces to form objects.
This script is improperly formatted because it starts with double curly braces `{{` which is not a valid JSON root element; JSON must begin with either a single curly brace `{` for an object or a square bracket `[` for an array.
This script is properly formatted JSON because it begins and ends with curly braces, indicating a root object, which contains a key-value pair where the key `car` maps to a nested object containing valid, comma-separated key-value pairs.
This script is improperly formatted because it starts with square brackets `[`, indicating an array, but then places a single key-value pair directly inside the array, which is syntactically incorrect; an array should contain a list of values (objects, strings, numbers, etc.), not direct key-value pairs.
Concept tested: JSON syntax and structure
Source: https://www.json.org/json-en.html
Topics
Community Discussion
No community discussion yet for this question.