-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpy_json.py
More file actions
22 lines (16 loc) · 727 Bytes
/
py_json.py
File metadata and controls
22 lines (16 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# JSON is commonly used with data APIs. Here's how we can parse JSON into a python dictionary
# if u call this file json.py we get a conflict because that's the name of the module
# That's why we call it py_json.py
# Let's import a json module
import json
# creating a Json(double Quotes is JSON Format)
CameraFXSettingsJSON = '{"Motion Blur":"Maximum","Vignette":"Rounded","Ambient Oclussion Distance":2.0}'
# Parse to dictionary
cameraFX = json.loads(CameraFXSettingsJSON)
print(cameraFX)
print(cameraFX['Motion Blur'])
# Creating a dictionary
cameraLens = {'Shutter':5.2,'model':'CANON X789'}
cameraLensJSON = json.dumps(cameraLens)
# Serialize object to formatted JSON
print (cameraLensJSON)