Python Language / Python JSON

It is used for encoding and decoding JSON data or for storing and exchanging data JSON data. Json means (Java Script Object Notation).

Program Output

# JSON to Python conversion program

import json
Fruit =  '{ "FruitNameame":"Apple", "Price":20}'
# parse Fruit
v = json.loads(Fruit)
print(v["FruitNameame"])
print(v["Price"])

Apple 20

# Python  to JSON conversion program

import json
Fruit = {
  "Name": "Apple",
  "Price": "20",
}
# convert into JSON:
vn = json.dumps(Fruit)
print(vn)

{"Name": "Apple", "Price": "20"}


Home     Back