200-301 · Question #147
Which of the following is the JSON encoding of a dictionary or hash?
The correct answer is A. {"key": "value"}. In JSON (JavaScript Object Notation), a dictionary or hash is represented as an object, which is enclosed in curly braces and contains key-value pairs where keys are strings.
Question
Which of the following is the JSON encoding of a dictionary or hash?
Options
- A{"key": "value"}
- B["key", "value"]
- C{"key", "value"}
- D("key": "value")
How the community answered
(18 responses)- A89% (16)
- B6% (1)
- D6% (1)
Why each option
In JSON (JavaScript Object Notation), a dictionary or hash is represented as an object, which is enclosed in curly braces and contains key-value pairs where keys are strings.
In JSON, a dictionary or hash is represented as an object, which is enclosed within curly braces `{}` and consists of one or more key-value pairs where the keys are strings enclosed in double quotes, such as `{"key": "value"}`.
This represents a JSON array, which is an ordered list of values, not a dictionary or hash.
This is invalid JSON syntax for an object; key-value pairs must be separated by a colon (`:`), not just a comma (`,`).
This uses parentheses `()` instead of curly braces `{}`, which is not the correct syntax for defining a JSON object.
Concept tested: JSON object syntax
Source: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-json-format
Topics
Community Discussion
No community discussion yet for this question.