Bird
0
0

Which of these is the correct JSON format for a consistent REST API response containing a user's name and age?

easy📝 Syntax Q3 of 15
Rest API - Request and Response Format
Which of these is the correct JSON format for a consistent REST API response containing a user's name and age?
A{"name": "Alice", "age": 30}
B{"Name": "Alice", "Age": "30"}
C{"user_name": "Alice", "user_age": 30}
D["Alice", 30]
Step-by-Step Solution
Solution:
  1. Step 1: Check for consistent key naming and data types

    {"name": "Alice", "age": 30} uses lowercase keys and age as a number, which is common and consistent.
  2. Step 2: Compare other options for consistency

    {"Name": "Alice", "Age": "30"} uses uppercase keys and age as string, inconsistent with typical API standards.
  3. Final Answer:

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

    Consistent keys and types = {"name": "Alice", "age": 30} [OK]
Quick Trick: Use lowercase keys and correct data types in JSON [OK]
Common Mistakes:
  • Using inconsistent key casing
  • Representing numbers as strings
  • Using arrays instead of objects for key-value data

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes