134 Part I: Core Ideas
Legal JSON number values have quite a range of forms, just as they do in JavaScript:
3
-1968
200001
- 0.9
3333.409
3e+1
4E-2
-0.45E+10
Arrays are just as they would be in JavaScript when containing only literals, a list of
values separated by commas:
array
[]value
,
An example of arrays in JSON follows:
["Larry", "Curly", "Moe", 3, false]
JSON objects are similar to the object literal format found in JavaScript except that the
properties will always be strings rather than identifiers:
object
{}string value
,
:
For example:
{"firstname": "Thomas", "lastname" : "Powell" , "author" : true,
"favoriteNumber" : 3 , "freeTime" : null}
JSON values can nest, thus the following more complex examples are legal JSON structures:
[ {"name" : "Larry" , "hair" : true },
{"name" : "Curly" , "hair" : false },
{"name" : "Moe" , "hair" : true }
]
{ "primaryStoogeNames" : ["Larry", "Curly", "Moe"],
"numberofStooges" : 3,
"alternateStooges" : [ {"name" : "Shemp", "original" : true } ,
{"name" : "Joe", "original" : false } ,
{"name" : "Curly Joe", "original" : false }
]
}