-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession16.py
More file actions
36 lines (26 loc) · 751 Bytes
/
session16.py
File metadata and controls
36 lines (26 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import json
# Java Script Object Notation
employee = {"eid":101, "name":"John", "salary":30000}
print(employee)
print(type(employee))
# Json -> string representation of dictionary
print()
# Convert Dictionary into JSON
# JSON is a textual i.e String representation of a Dictionary
# dumps fnc converts dict to string(JSON)
jsonData = json.dumps(employee)
print(jsonData)
print(type(jsonData))
print() # o/p in double quotes
""""
jsonData = str(employee)
print(jsonData)
print(type(jsonData)) # o/p in single quote
"""
# Get the JSON data i.e string format of dictionary
# and convert it into Dictionary
dictData = json.loads(jsonData)
print(dictData)
print(type(dictData))
# str cannot be converted back to dict
#print(dictData['status'])