I'm trying to parse key value pairs(fname and jobcode) after performing get request. What's the best way to parse key value pairs to perform tasks?
Below is my get request response on
response = requests.get('url')
Result:
[
{
"fname": "James",
"jobcode": "51202"
},
{
"fname": "Jim",
"jobcode": "32304"
}
]
Tried it this way, and got AttributeError: 'list' object has no attribute 'items'
.
json_data = json.loads(response.text)
print json_data
for key, value in json_data.items():
print key, value
I want to translate it into a list like [James, 51202], [Jim, 32304]
so that I can easily use. Or, I'd like to just get key value pairs so that I can iterate over them.