May 10, 2021 Java
The JSON syntax is a subset of the JavaScript object representing the syntax.
,
.
,
by .
JSON supports two data structures:
Data | Describe |
---|---|
A collection of name/value pairs | key:value,key:value, |
An ordered list of values | [1,2,3,4] |
In JSON, the value must be one of the following data types:
In JavaScript, all listed above can be values, plus other valid JavaScript expressions, including:
In JSON, string values must be written in double quotes
JSON data is written as a name/value pair.
The name/value consists of a field name, followed by a colon and a value:
"name":"W3Cschool"
Equivalent to:
name = "W3Cschool"
The JSON name requires double quotes. The JavaScript name is not required.
JSON - The value is a JavaScript object
The JSON format is almost identical to JavaScript objects.
In JSON, the key must be a string, surrounded by double quotes:
{ "name":"W3Cschool" }
In JavaScript, the key can be a string, number, or identifier name:
{ name:"W3Cschool" }
The following JSON data specifies the book.
{ "book": [ { "id":"01", "language": "Java", "edition": "third", "author": "java2s.com" }, { "id":"02", "language": "JSON", "edition": "second" "author": "java2s.com" }] }