JSON Data Format

JSON (JavaScript Object Notation) is a text, formatted according to specific rules. A person can easily read it, and a computer can quickly process it. JSON is used to transmit and store information.

{
    "i_am_json_key": "I am json value"
}

Example of text in JSON format

Example of a JSON object

In everyday life, we often describe objects by their characteristics — for example, a cat has a name. A JSON object follows this idea and describes the object's properties as key-value pairs.

key is the name

value is the information stored under that key

For example, a JSON object can contain

Key Value
name Mia
age 2
character_traits
friendliness
playfulness
cat-mia
Example of data in JSON format

Rules for Forming a JSON Object

Curly braces denote the beginning and end of the JSON object body
{

}
All keys are enclosed in double quotes
{
  "key": "value"
}
String values are enclosed in double quotes
{
  "key": "string value"
}
Numeric values are written without quotes
{
  "key": 1
}
Square brackets are used to denote an array of homogeneous data
{
  "key": [
    "string value 1",
    "string value 2"
  ]
}
Key names are commonly written using snake_case
{
  "key_with_multiple_words": "value"
}

You can read more about JSON formatting rules at json.org.

Header Content-Type: application/json

Earlier we discussed what the HTTP protocol is and learned that HTTP requests and responses can contain additional information — headers.

Header Content-Type define the type of transmitted content and can have values like:
  • text/html
  • image/jpeg
  • application/json
  • and others...

When transmitting data in JSON format, it is necessary to specify the header Content-Type: application/json.

content-type
Content-Type Header of HTTP Request in DevTools
Task
Task available to premium users!

Unlock access to learn without limits.

Full access to all practical tasks
Answer checking
Unlimited attempts
Sidebar arrow