JSON Data Format
The syntax of JSON is inspired by JavaScript Object literal and is used to describe data structure.
JSON supports the following data formats:
- String
- Number
- Boolean (boolean)
- Null
- Object
- Array
JSON string (String)
In JSON string with two double quotation marks "
enclose text.
example:
"hello fooish.com"
{"name": "Mike"}
JSON number (Number)
The value of JSON can be integer or floating point.
example:
600
55.66
-30
{"age": 25}
JSON Boolean (Boolean)
There are two boolean values are true
or false
.
example:
false
{"disable": true}
JSON null (null)
null
The value means a null value.
example:
null
{"middlename": null}
JSON object (Object)
An object that contains a series of key-value pair (key-value pairs) of storage format, an object to {
begin, and finally to }
a symbol ends, each key-value pair comma ,
separated, and between the key and value are used colon :
separated.
The key in the object key-value pair must be a string format; and the value can be any JSON data format.
example:
{
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
{"count": 101}
JSON array (Array)
The array is an ordered sequence, and an indefinite number of values can be stored in the array.
An array [
starts, and finally to ]
the symbol end, if there are multiple values with a comma ,
separated value array may be any data format JSON.
example:
["Stacey", "John", "Jimmy"]
[100]
{"tags": ["xmas", "green"]}
Whitespace in JSON
Blank characters in JSON, as long as they are not enclosed in double quotes in the string, will be automatically ignored.
For example, the following two examples have the same meaning:
{
"tags": [ "xmas", "green" ]
}
{"tags":["xmas","green"]}
Post a Comment
0 Comments