What is a JSON format

1 min

JSON format is an industry standard.

It is a data format, mainly used to exchange data on the web.

Example:

  • Facebook.com when you request your profile
  • Youtube.com when you ask for new videos

A lot of services rely on JSON data format.

What does it look like ?

{
  "Address": "9611-9809 West Rosedale Road",
  "Longitude": -98.5259864,
  "Email": "[email protected]",
  "Created At": "2017-10-07T01:34:35.462",
  "Password": "ccca881f-3e4b-4e5c-8336-354103604af6",
  "Source": "Twitter",
  "ID": 1,
  "Zip": "68883",
  "Latitude": 40.71314890000001,
  "Birth Date": "1986-12-12",
  "City": "Wood River",
  "State": "NE",
  "Name": "Hudson Borer"
}

It works in a key:value format.

as so...

{
  "key": "value"
}

This format is easily readable in any programming language, but in Python it looks like this.

It can be read from a file :

import json # The built-in json library that we use to read json files

# We read the json file and assign its value to a Python dictionnary 
with open("path/to/file.json") as file:
	data = json.loads(file)

print(data)
A json file

Or from a Python string :

import json # The built-in json library that we use to read json files

my_json_string = '{
  "Address": "9611-9809 West Rosedale Road",
  "Email": "[email protected]"
}'

data = json.loads(my_json_string)

print(data)
Or a Python string