DEV Community

Cover image for What is JSON?
compilerboiler
compilerboiler

Posted on

What is JSON?

JSON is the most widely used format for interchanging data on the web. Its meaning is "Java Script Object Notation".

It originates from the JavaScript language. JSON uses the JavaScript syntax, but the JSON format is text only.

Example

The data below is in json format:

{"employees":[
{"name":"Alice", "email":"alice@xyz.com"},
{"name":"Alex", "email":"alex@xyz.com"},
{"name":"Allison", "email":"allison@xyz.com"}
]}

Its easily readable by a computer and human (compared to the XML format).

You can convert any JavaScript object into JSON and send JSON to the server.

But what's more:

  • JSON is a cross language data format
  • JSON is both more compact and (in my view) more readable
  • You can convert json to Python objects
  • You can convert json to Python Pandas Dataframe, then to csv or Excel
  • You can convert Python objects to json

Json text can be read and used as a data format by any programming language.

One of the ways to use it, is the json module:

import json
data = '{"name": "Alice", "city": "Amsterdam"}'
python_obj = json.loads(data)
print python_obj["name"]

But the pandas module may be better suited. Pandas is a data analysis module and it supports many features like reading and writing excel.

You can read json in Python Pandas.

Reference:
json module
json examples

Top comments (0)