A name-value pair, usually called a key-value pair, connects an identifying key on the left with its associated data on the right. In JSON, the key comes first, followed by a colon and the value; commas separate pairs inside an object. section 3.5.2
A JSON key-value pair has a small but useful vocabulary:
- Keys must be strings enclosed in double quotation marks. section 3.5.2
- Values may be strings, numbers, Booleans, arrays, objects, or null. section 3.5.2
- Nesting pairs inside objects makes related data easier to name, although deeper structures can become harder to read. section 3.5.2
Fruit taste scores
An object can pair each fruit name with a numerical taste score: “Bananas” maps to 80, while “Oranges” maps to 50. A more elaborate structure can instead use an index as the outer key and nest fruit and taste-score pairs inside it. section 3.5.2
{
"Fuyu Persimmons": 100,
"Mangos": 100,
"Peaches + Nectarines": 100,
"Bananas": 80,
"Kiwis": 70,
"Apples": 60,
"Oranges": 50
}
Inspect a compact object whose seven key-value pairs connect fruit names with taste scores. section 3.5.2










