string =" {
"status": "error",
"messages": ["Could not find resource or operation 'BZK1.MapServer' on the system."],
"code": 404
}"
print 'objects:' string
print 'Value:' json.loads (string) [ 'code']
The output is:
对象:{u'status': u'error', u'code': 404, u'messages': [u"Could not find resource or operation 'BZK1.MapServer' on the system."]}
Value: 404
The object into a string:
resultJson = {"state": 1} print json.dumps(resultJson)
We were used Json package loads () method and dumps () method
string =" {
"status": "error",
"messages": ["Could not find resource or operation 'BZK1.MapServer' on the system."],
"code": 404
}"
print 'objects:' string
print 'Value:' json.loads (string) [ 'code']
The output is:
对象:{u'status': u'error', u'code': 404, u'messages': [u"Could not find resource or operation 'BZK1.MapServer' on the system."]}
Value: 404
The object into a string:
resultJson = {"state": 1} print json.dumps(resultJson)
We were used Json package loads () method and dumps () method