Bird
0
0

Given this JSON request body sent to an API:

medium📝 Predict Output Q13 of 15
Rest API - Request and Response Format
Given this JSON request body sent to an API:
{
  "name": "Alice",
  "age": 30
}

What will the server receive as the value of age?
AUndefined
B"30" (string)
Cnull
D30 (number)
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the JSON data types

    The value for age is written as 30 without quotes, so it is a number, not a string.
  2. Step 2: Understand server parsing

    The server parses JSON and keeps numbers as numbers, so age will be the number 30.
  3. Final Answer:

    30 (number) -> Option D
  4. Quick Check:

    Unquoted numbers in JSON = number type [OK]
Quick Trick: Numbers in JSON have no quotes, so parsed as numbers [OK]
Common Mistakes:
MISTAKES
  • Assuming all JSON values are strings
  • Confusing number and string types
  • Ignoring JSON parsing rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes