Bird
0
0

A PATCH request updates a nested resource field, such as address.city. Which JSON body correctly updates only the city without affecting other address fields?

hard📝 Application Q9 of 15
Rest API - HTTP Methods
A PATCH request updates a nested resource field, such as address.city. Which JSON body correctly updates only the city without affecting other address fields?
A{"address": {"city": "Newtown"}}
B{"city": "Newtown"}
C{"address.city": "Newtown"}
D{"address": "Newtown"}
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested JSON structure

    To update a nested field, the JSON must include the parent object with the updated child field.
  2. Step 2: Evaluate options

    {"address": {"city": "Newtown"}} correctly nests city inside address; others either flatten or overwrite incorrectly.
  3. Final Answer:

    {"address": {"city": "Newtown"}} -> Option A
  4. Quick Check:

    Nested update requires nested JSON object [OK]
Quick Trick: Use nested objects to update nested fields [OK]
Common Mistakes:
MISTAKES
  • Using dot notation keys in JSON
  • Sending only nested field without parent object
  • Replacing whole parent object unintentionally

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes