[go: up one dir, main page]

0% found this document useful (0 votes)
55 views3 pages

JSON Cheat Sheet

The document is a JSON Cheat Sheet that outlines the syntax and core components of JSON, including key/value pairs, arrays, and objects. It describes the six types of values in JSON: arrays, objects, strings, numbers, booleans, and null. Additionally, it provides examples to illustrate how JSON data is structured and formatted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views3 pages

JSON Cheat Sheet

The document is a JSON Cheat Sheet that outlines the syntax and core components of JSON, including key/value pairs, arrays, and objects. It describes the six types of values in JSON: arrays, objects, strings, numbers, booleans, and null. Additionally, it provides examples to illustrate how JSON data is structured and formatted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Three. Two.

Online

JSON
Cheat Sheet
</>
JSON Cheat Sheet 1

Start your own website with unlimited hosting.


Use HostingerTutorials discount code and USE IT TODAY
get up to 83% OFF for any web hosting plan.

JSON Cheat Sheet


JSON Syntax
The JSON syntax is largely a subset of the JavaScript syntax. Here are its core components:

Key/value pairs represent data.


Data is separated by commas.
Curly brackets {} represent objects.
Square brackets [] delineate arrays.

Therefore, JSON syntax looks like this:

{“key”:“value”,“key”:“value”,“key”:“value”.}

Types of Values
There are six kinds of values in JSON.

1 Arrays
An array is an ordered list of values that are surrounded by square brackets,
each separated by a comma. For example:

[
{"firstName":"Jack", "lastName":"Smith"},
{"firstName":"Jane", "lastName":"Perkins"},
{"firstName":"Richard", "lastName":"Kilmer"}
]

2 Objects
An object contains a key and value separated by a colon. There is a comma after
every pair. All elements are inside sets of quotation marks. For example:

{
"spouse":{
"firstName":"John",
"lastName":"Smith"
}
}

HOSTINGER Three. Two. Online


JSON Cheat Sheet 2

3 Strings
A string is a set of sequences of zero or more Unicode characters with double
quotation marks enclosing them. For example:

{"city":"London"}

4 Numbers
A number contains either an integer or a floating point. For example:

{“age”:45}

5 Boolean
A boolean contains true or false as values. For example:

{“active”:true)

6 Null
This value shows that there is no information. For example:
your web content should be easy to perceive for any visitor.
{"middleName":null}

Coding with JSON


Here is an example of JSON data:

{
Here’s what each pair indicates:
"name":"Jennifer",
"age":39, "name":"Jada" is a string.
"religion":null, "age":39 is a numeric value.
"married":true, "religion":null represents a null.
"spouse":{"firstName":"John", "lastName":"Smith"}, "married":true is a boolean.
"children":[{ "spouse":{"firstName":"John",
"firstName":"Jackson","lastName":"Smith"}, "lastName":"Smith"} is an object literal.
{"firstName":"Jackie","lastName":"Smith"}, An array is represented from the sixth
{"firstName":"Jacob","lastName":"Smith"}, line onwards.
{"firstName":"Jacinda","lastName":"Smith"},
]
}

HOSTINGER Three. Two. Online

You might also like