Bird
Raised Fist0

Which JSON structure correctly represents a nested error for a REST API response?

easy📝 Syntax Q12 of Q15
Rest API - Error Handling

Which JSON structure correctly represents a nested error for a REST API response?

{
  "error": {
    "message": "Invalid input",
    "details": {
      "field": "email",
      "error": "Invalid format"
    }
  }
}
A{ "error": "Invalid input", "details": "email error" }
B{ "message": "Invalid input", "field": "email" }
C{ "error": ["Invalid input", "email error"] }
D{ "error": { "message": "Invalid input", "details": { "field": "email", "error": "Invalid format" } } }
Step-by-Step Solution
Solution:
  1. Step 1: Identify nested JSON error format

    Nested error reporting uses objects inside objects to show details clearly.
  2. Step 2: Match the correct JSON structure

    { "error": { "message": "Invalid input", "details": { "field": "email", "error": "Invalid format" } } } shows an error object with a message and nested details object with field and error.
  3. Final Answer:

    { "error": { "message": "Invalid input", "details": { "field": "email", "error": "Invalid format" } } } -> Option D
  4. Quick Check:

    Nested JSON error = { "error": { "message": "Invalid input", "details": { "field": "email", "error": "Invalid format" } } } [OK]
Quick Trick: Look for nested objects inside error key [OK]
Common Mistakes:
MISTAKES
  • Using arrays instead of objects for nested errors
  • Missing nested details object
  • Flattening error info without nesting

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes