Datatypes in JSON

JSON supports six data types- Numbers, Strings, Booleans, Arrays, Objects, and null. Following table describes them in detail-

Data Type Description
Numbers It can be an integer or floating point
Strings Any Unicode characters placed inside double or single quotes.
Booleans It represents true or false
Arrays It is an ordered list of values separated by a comma enclosed in square brackets
Objects It is a collection of key:value pairs.
Null It means empty.

Example

This illustration will show the usage of these data types-

{
	"name":"Black T-Shirt",
	"price":300,
	"sizes":[32, 34, 36, 38],
	"inStock":true,
	"seller":{
		"name":"Stylish Shop",
		"rating":5.0
	}
}

Here name key contains string value, price key contains number value, sizes refer to an array, inStock points to boolean, seller is an object.