json.loads
will load a json string into a python dict
, json.dumps
will dump a python dict
to a json string, for example:
>>> json_string = '{"favorited": false, "contributors": null}'
'{"favorited": false, "contributors": null}'
>>> value = json.loads(json_string)
{u'favorited': False, u'contributors': None}
>>> json_dump = json.dumps(value)
'{"favorited": false, "contributors": null}'
So that line is incorrect since you are trying to load
a python dict
, and json.loads
is expecting a valid json string
which should have <type 'str'>
.
So if you are trying to load the json, you should change what you are loading to look like the json_string
above, or you should be dumping it. This is just my best guess from the given information. What is it that you are trying to accomplish?
Also you don't need to specify the u
before your strings, as @Cld mentioned in the comments.