Bird
Raised Fist0

Which of the following is the correct way to represent a simple dictionary in JSON format?

easy📝 Syntax Q12 of Q15
Python - Structured Data Files
Which of the following is the correct way to represent a simple dictionary in JSON format?
A{name: Alice, age: 30}
B{"name": "Alice", "age": 30}
C["name" => "Alice", "age" => 30]
D("name" = "Alice", "age" = 30)
Step-by-Step Solution
Solution:
  1. Step 1: Recall JSON syntax rules

    JSON requires keys and string values to be in double quotes, and key-value pairs separated by colons.
  2. Step 2: Compare options to JSON format

    {"name": "Alice", "age": 30} uses double quotes and colons correctly; others use invalid syntax.
  3. Final Answer:

    {"name": "Alice", "age": 30} -> Option B
  4. Quick Check:

    JSON keys and strings use double quotes [OK]
Quick Trick: JSON keys and strings always use double quotes [OK]
Common Mistakes:
MISTAKES
  • Using single quotes instead of double quotes
  • Using equal signs or arrows instead of colons
  • Omitting quotes around keys or string values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes