- Home
- API Design
- How to use JSON Data Types?

A JSON body can comprise one of 6 data types which can be categorized as primitive or complex data types.
JSON Data Type
- String (Primitive)
- Number(Primitive)
- Object (Complex)
- Array (Complex)
- Boolean (Primitive)
- Null (Primitive)
1. String
In JSON, keys must always be strings. Any string is always written in double quotes.
Example
{
"name": "apitier"
}2. Number
The number represents the numeric characters. Number values must be integer or floating-point numbers. A floating-point number is a number with a decimal point value such as; 0, 3.11, 7.3, and -109.5.
Example
{
"age": 50
}{
"percentage": 80.55
}3. Object
It is a set of name or value pairs inserted between {} (curly braces). The keys must be strings and should be unique and multiple keys and value pairs are separated by a, (comma).
Syntax
{ key : value, .......}
Example
{
"user": {
"name": "apitier",
"age": 50,
"percentage": 60.05
}
}4. Array
The array is a list of objects, which are mainly enclosed in square brackets [ ]. In JSON, the array value can be a string, number, object, array, boolean or null.
Syntax
[ value, .......]
Example
{
"apitier": [
"postcode",
"address",
"post_town"
]
}
{
"addresses": [
{
"line_1": "House Of Commons",
"line_2": "Houses Of Parliament",
"line_3": "",
"post_town": "LONDON",
"postcode": "SW1A 0AA",
"address": "House Of Commons, Houses Of Parliament, LONDON, SW1A 0AA"
}
]
}5. Boolean
This data type can be either true or false.
Example
{
"result" : true
}6. Null
It is just a defined nullable value(empty value).
Example
{
"result" : true,
"grade" : null,
"no" : 210
}


