Convert JSON string to dict using Python Convert JSON string to dict using Python python python

Convert JSON string to dict using Python


json.loads()

import jsond = json.loads(j)print d['glossary']['title']


When I started using json, I was confused and unable to figure it out for some time, but finally I got what I wanted
Here is the simple solution

import jsonm = {'id': 2, 'name': 'hussain'}n = json.dumps(m)o = json.loads(n)print(o['id'], o['name'])


use simplejson or cjson for speedups

import simplejson as jsonjson.loads(obj)or cjson.decode(obj)


matomo