Example of Writing JSON format
Here is an example of how to write JSON format. Suppose we want the states’ high/low temperature data in JSON format.
Wikipedia’s record of the high/low temperatures can be seen there.
I re-wrote that data in JSON format linked here. I entered a few records with all the information. And then in the later records, I omitted some of the data such as Celsius temperature and dates.
Just to make sure there is no typo, I ran it through a JSON validator such as JSONLint.com. The nice thing is that it also prettied up the format so that it looks like …
As you can see, I started the file with [ and ended it with ] so that it is an array of objects separated by comma. Each object being a “record” with properties such as “state”, “high”, and “low”. The properties are in key/value pair separated by comma as in …
“state”: “Alabama”
where “Alabama” is a string value.
But values can be objects as well. The value of “high” and “low” are both objects with their own properties nested.
The syntax map for JSON can be found on json.org.
If I had replaced [ ] with { } at the start and end of file, it would not validate.