Always check that your JSON is valid before sending it in Postman.
Use online JSON validators or Postman's built-in validation to avoid errors.
Remember that JSON keys are case-sensitive.
Summary
JSON body is a way to send structured data in API testing.
It uses key-value pairs with keys and string values in double quotes.
JSON can include strings, numbers, booleans, arrays, and nested objects.
Practice
(1/5)
1. What is the correct way to represent a JSON body with a user's name and age in Postman?
easy
A. {"name": "Alice", "age": 30}
B. {name: Alice, age: 30}
C. {'name': 'Alice', 'age': 30}
D. {name = "Alice", age = 30}
Solution
Step 1: Identify JSON syntax rules
JSON keys and string values must be in double quotes. Numbers do not need quotes.
Step 2: Check each option for correct JSON format
{"name": "Alice", "age": 30} uses double quotes correctly around keys and string values. The other options use incorrect quotes or syntax.
Final Answer:
{"name": "Alice", "age": 30} -> Option A
Quick Check:
JSON keys and strings use double quotes = A [OK]
Hint: Always use double quotes for keys and string values in JSON [OK]
Common Mistakes:
Using single quotes instead of double quotes
Omitting quotes around keys
Using equal signs instead of colons
2. Which of the following is a valid JSON body to send a list of colors in Postman?
easy
A. {"colors": ("red", "green", "blue")}
B. {colors: [red, green, blue]}
C. {"colors": "red", "green", "blue"}
D. {"colors": ["red", "green", "blue"]}
Solution
Step 1: Understand JSON array syntax
Arrays in JSON are enclosed in square brackets with comma-separated values, strings in double quotes.
Step 2: Validate each option's array format
{"colors": ["red", "green", "blue"]} correctly uses square brackets and double quotes. The other options are invalid: one uses parentheses, another is missing array brackets, and one lacks quotes around strings and keys.
Final Answer:
{"colors": ["red", "green", "blue"]} -> Option D
Quick Check:
Arrays use square brackets and double quotes = B [OK]
Hint: Use square brackets for arrays and double quotes for strings [OK]