Syntax is like grammar for computers—it’s the rules for how you write instructions. If you mess up the order, spelling, or punctuation, the computer won’t understand you at all. Just like sentences need periods and spaces, code needs things like braces {} and colons : in the right spots.
JSON syntax has a few basic rules.
Data is in key/value pairs
JSON data is written as name/value pairs (aka key/value pairs).
A key/value pair consists of a key (always a string in double quotes), followed by a colon : , followed by a value:
"Address" : "221b Baker Street"
"Length": 23000
Keys are always strings
String values must have
" "Number values do not use
" "
A key/value pair in Giraffe:
Curly braces hold objects
An object is basically a group of one or more key/value pairs. Objects are contained by curly braces { }
{
"Address" : "221b Baker Street",
"Tenant" : "Holmes",
"Rent" : 2500
}
An object in Giraffe:
Data is separated by commas
Each key/value pair, object, and array must be separated by a comma ,
{
"Address" : "221b Baker Street",
"Tenant" : "Holmes",
"Rent" : 2500
}Note: the last key/value pair is not followed by a comma. It is not being separated from anything following, so it is not needed.
Key/value pairs separated by commas in Giraffe:
Square brackets hold arrays (lists)
In JSON, an array is like a list of things written inside square brackets [ ].
An array can contain multiple values:
"Tenants" : ["Holmes", "Watson"]
An array in Giraffe:
An array can also contain multiple objects:
221 Baker Street:{
"Units" : [
{
"Address" : "221b Baker Street",
"Tenant" : "Holmes",
"Rent" : 2500
},
{
"Address" : "221a Baker Street",
"Tenant" : "Hudson",
"Rent" :
}
]
}
An array of Objects in Giraffe:






