Bird
0
0

Given this JSON request body sent to an API:

medium📝 Predict Output Q4 of 15
Rest API - Request and Response Format
Given this JSON request body sent to an API:
{"product": "Book", "quantity": 3}

What will the server receive as the value of quantity?
Aundefined
B3
Cnull
D"3"
Step-by-Step Solution
Solution:
  1. Step 1: Understand JSON number types

    Numbers in JSON are sent as numeric values without quotes, so quantity is a number 3.
  2. Step 2: Differentiate from string and null

    Quoted "3" would be a string, null means no value, undefined is not valid JSON.
  3. Final Answer:

    3 -> Option B
  4. Quick Check:

    Unquoted numbers in JSON = numbers [OK]
Quick Trick: Numbers in JSON are unquoted values [OK]
Common Mistakes:
  • Treating numbers as strings
  • Confusing null with zero
  • Expecting undefined in JSON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes