Reputation: 21
While loading below json into json.loads()
, I get error on "value"
as it does not contain ""
.
jstring = '{"ABC": {value: "2787456", basevalue: "34453176"}}'
Upvotes: 0
Views: 167
Reputation: 7418
The problem is that value
must also be enclosed in quote marks like this "value"
, in order to be parsed as json key.
jstring = '{"ABC": {"value": "2787456", "base value": "34453176"}}'
Upvotes: 0
Reputation: 122336
Keys need to be enclosed in double quotes:
>>> jstring='{"ABC":{"value":"2787456","basevalue":"34453176"}}'
>>> import json
>>> json.loads(jstring)
{u'ABC': {u'value': u'2787456', u'basevalue': u'34453176'}}
Upvotes: 2