Download our e-book of Introduction To Python
Neha Kumawat
3 years ago
import json
data=['Rakesh',{'marks':(50,60,70)}]
s=json.dumps(data)
json.loads(s)
e=json.JSONEncoder()
e.encode(data)
d=json.JSONDecoder()
d.decode(s)
import json
data=['Rakesh', {'marks': (50, 60, 70)}]
fp=open('json.txt','w')
json.dump(data,fp)
fp.close()
["Rakesh", {"marks": [50, 60, 70]}]
fp=open('json.txt','r')
ret=json.load(fp)
print (ret)
fp.close()
['Rakesh', {'marks': [50, 60, 70]}]
C:\python37>python -m json.tool json.txt
[
"Rakesh",
{
"marks": [
50,
60,
70
]
}
]