I'm working w/the twitter search API and using python to parse the data coming back. I'm a python-noob, so my error is probably my lack of understanding, though I'm stuck.
My response looks like this:
And my code; "responseJson" is a file that I've saved the response from twitter to for continued testing w/out hitting the API.
responseJson = json.loads(open(DEBUG_JSON).read())
for key, value in responseJson.iteritems():
if key == 'results':
print "type: ", type(value)
for tweetKey, tweetValue in value.iteritems():
print tweetKey
When I execute the program, I get:
$ python search.py
type: <type 'list'> <-- says it's a list!
Traceback (most recent call last):
File "search.py", line 46, in <module>
for tweetKey, tweetValue in value.iteritems():
AttributeError: 'list' object has no attribute 'items'
You can see the output says "value" is a list, which means I should be able to call iteritems() on it. I'm albe to call iteritems() on "responseJson just fine.
Any help / clarity is appreciated, TIA!