import json
d = '{"var1": "Aakash", "var2":34}'
r = json.loads(d)
# print(r)
data2 = {
"name":"Aakash",
"roll": 253,
}
# json.dumps it will convert dictionary into json format so that we can use in javascript
js = json.dumps(data2)
# print(js)
d4 = {
"a": "Aakash",
"d": "ravi",
"c": "karan",
"b": "Rohit",
}
# sort_key will arrange key in alphabtic order
j= json.dumps(d4,sort_keys=True)
# separators will seprate data with your requirements
j2= json.dumps(d4,separators=(". "," = "))
# indent will give indentation of you data
j3 = json.dumps(d4, indent=5)
print(j3)
Comments
Post a Comment