python - How to read field from JSON encoding of XML message -
is there way can errormessage
tag response using code in python?
{ "movies_search":{ "@xmlns":"http://www.ourmoviest.com/mv", "@xmlns:xsi":"http://www.w3.org/2001/xmlschema-instance", "@xsi:schemalocation":"http://www.ourmoviest.com/mv mv.xsd ", "error":{ "errormessage":"we cannot proceed search", "statuscode":"00004" } } }
the following python script,
import json respstr = """ { "movies_search":{ "@xmlns":"http://www.ourmoviest.com/mv", "@xmlns:xsi":"http://www.w3.org/2001/xmlschema-instance", "@xsi:schemalocation":"http://www.ourmoviest.com/mv mv.xsd ", "error":{ "errormessage":"we cannot proceed search", "statuscode":"00004" } } } """ respobj = json.loads(respstr) print respobj['movies_search']['error']['errormessage']
will print errormessage
string,
we cannot proceed search
as requested.
Comments
Post a Comment