What is JSON? | Yext Hitchhikers Platform
What You’ll Learn
In this section, you will learn:
- What is JSON?
- Definitions of JSON Components
What is JSON?
JSON stands for JavaScript Object Notation and is used for storing and exchanging data in text format. The benefit of JSON is that because it’s simply text, you’re able to send this data really easily to any application that needs to use it. You’ll see many APIs, configuration files, and much more defined in JSON format.
Glossary of Terms with JSON
Key / Value Pair: These define a property and its value in a JSON object. The key is the phrase to the left of the colon in a key/value pair, describing the property. These are also called dictionaries - just as a dictionary has a set of unique words associated with their definition, a JSON dictionary will have a set of unique keys associated with their value.
"key1": "value1"
The value of a JSON key is the phrase to the right of the colon in a key/value pair.
Values can be of several types. They can be text, which must be contained in quotation marks. They can be numbers, which do not need to be contained in quotation marks. They can also be JSON literals, which is a value of either true, false, or null.
Lastly, values can also be objects in themselves. You’ll often see ‘nested’ objects in this way to define more complex data structures.
The table below summarizes the potential value types.
Value Type | Description | Requires Quotations? |
---|---|---|
text | Free-form, can contain any text value | yes |
number | Must be a valid numeric value | no |
literal | Either true , false , or null |
no |
object | Another JSON object | no |
Object or Dictionary: A JSON object is a collection of key/value pairs, contained with curly brackets { }
. In an object, key/value pairs are separated by commas.
{
"key1": "value1",
"key2": "value2",
"key3": false
}
Note that objects can be nested within one another - that is, a property of a parent object can have a value of another object. You’ll see this frequently with the JSON you’ll encounter.
Array: A JSON Array is a list of items, contained in square brackets [ ]
.
[
"Item1",
"Item2",
"Item3"
]
Common Examples of JSON Usage
You’ll see JSON very frequently as you interact with different Yext products:
- Our APIs return and consume data in JSON format (see Introduction to APIs )
- Our Pages site configuration is defined in JSON
- Our Search backend configuration is defined in JSON
And much, much more! It’s important to understand the common syntax errors you might encounter to ensure your formatting is correct for any use case that requires JSON.