JSON Concepts: Difference between revisions
Jump to navigation
Jump to search
(→Arrays) |
|||
Line 43: | Line 43: | ||
==Objects== | ==Objects== | ||
Objects are enclosed in curly brackets "{}" and contain key/value pairs. The key and the value are separated by colon (":"). The pairs are delimited by commas (","): | |||
<pre> | |||
{ | |||
"id" : 42, | |||
"name" : "John Doe", | |||
"married" : true | |||
"kids" : [ "Alice", "Bob" ] | |||
} | |||
</pre> | |||
==Arrays== | ==Arrays== |
Revision as of 16:17, 25 February 2017
Internal
Data Types
JSON data types are: null, Booleans, Strings, Numbers, Objects (which can be thought of as Maps) and Arrays.
null
Booleans
Booleans are represented as
true false
and they are not quoted.
Strings
Strings are represented as:
"this is a string"
and they are quoted. Always use double quotes ("), never use single quotes (').
Numbers
Numbers are represented as:
10
and they are not quoted.
Objects
Objects are enclosed in curly brackets "{}" and contain key/value pairs. The key and the value are separated by colon (":"). The pairs are delimited by commas (","):
{ "id" : 42, "name" : "John Doe", "married" : true "kids" : [ "Alice", "Bob" ] }
Arrays
Array elements are enclosed in brackets "[", and they are separated by commas:
[ "one element", "another element" ]