json KeyError with json.loads

Posted by user322775 on Stack Overflow See other posts from Stack Overflow or by user322775
Published on 2010-04-21T23:24:10Z Indexed on 2010/04/21 23:33 UTC
Read the original article Hit count: 426

Filed under:
|

my apologies in advance for a python and json nubie question. json seems to be hiccuping on the following statements:

{"delete":{"status":{"id":12600579001,"user_id":55389449}}}

code snippet:

temp = json.loads(line)
text = temp['text']

I get the following error output when the above code snippet encounters lines similar to the above json 'dictionary':

text = temp['text']
KeyError: 'text'

Is it because there is no "text" key in the line or because "delete" is not in the dictionary?

© Stack Overflow or respective owner

Related posts about python

Related posts about JSON