1import json
2info = {
3 "data": {
4 "name": "Dave",
5 "City": "NY"
6 }
7}
8# With json.dump (into file)
9with open( "data.json" , "w" ) as x:
10 json.dump( info , x )
11# >>> {"data": {"name": "Dave", "City": "NY"}}
12
13# with json.dumps (object)
14data = json.dumps( info )
15print( data )
16# >>> {"data": {"name": "Dave", "City": "NY"}}