Skip to main content

JavaScript JSON Objects

A JSON object literal is a JavaScript object that is written in JSON syntax.

It consists of a set of key-value pairs enclosed in curly braces, with each key and value separated by a colon and each pair separated by a comma.

Here's an example of a JSON object literal:

{
"name": "John",
"age": 30,
"city": "New York"
}

In this example:

  • We have a JSON object with three key-value pairs. The keys are "name", "age", and "city", and the values are "John", 30, and "New York", respectively.
tip

The key names in a JSON object literal must be enclosed in double quotes, and the values can be any valid JSON data type, such as strings, numbers, booleans, arrays, or even other JSON object literals.