Bird
0
0

Which of the following is the correct JSON syntax for a simple error response with code 404 and message "Not Found"?

easy📝 Syntax Q12 of 15
Rest API - Error Handling
Which of the following is the correct JSON syntax for a simple error response with code 404 and message "Not Found"?
A{"error": {code: 404, message: "Not Found"}}
B{"error": {"code": 404, "message": "Not Found"}}
C{"error": {"code": "404", "message": Not Found}}
D{"error": {"code": 404, message: Not Found}}
Step-by-Step Solution
Solution:
  1. Step 1: Check JSON key and string syntax

    Keys and string values must be in double quotes. Numbers like 404 do not need quotes.
  2. Step 2: Identify the correct option

    {"error": {"code": 404, "message": "Not Found"}} uses correct quotes for keys and strings, and number 404 without quotes.
  3. Final Answer:

    {"error": {"code": 404, "message": "Not Found"}} -> Option B
  4. Quick Check:

    JSON keys and strings need double quotes [OK]
Quick Trick: Use double quotes for keys and string values in JSON [OK]
Common Mistakes:
  • Missing quotes around keys
  • Using quotes around numbers
  • Not quoting string values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes