i want to parse a POST HTTP response using python.
My response looks like:
{
"Result": 0,
"ResponseStatus": {
"ErrorCode": null,
"Message": null,
"StackTrace": null,
"Errors": null
},
"SessionId": "68ebcd6f-0aef-420d-a12b-c953f8df8ed1",
"ResponseHeader": {
"Succeeded": true,
"Errors": []
}
}
I want to parse the - "SessionID" to a 2nd http request. How can i achieve it? Thanks !
import json
response = '{"Result": 0, "ResponseStatus": { "ErrorCode": null,"Message": null, "StackTrace": null, "Errors": null },"SessionId": "68ebcd6f-0aef-420d-a12b-c953f8df8ed1", "ResponseHeader": { "Succeeded": true, "Errors": [] } }'
json_response = json.loads(response)
print json_response['SessionId']
I guess you are using urllib, I recommend using requests
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.