0

This is my response to a get request for some json goodness. I'm getting this in Python, everything works up to here. I've been searching for json documentation and reading quite a bit but can't seam to find my answer.

How would I get all the email addresses?

{u'-InFSLzYdyg-OcTosYYs': {u'email': u'[email protected]', u'time': 1360707022892}, u'-    InFYJya4K6tZa8YSzme': {u'email': u'[email protected]', u'time': 1360708587511}}

What I'd want is a list like so:

email = ['[email protected]', '[email protected]']

Thanks in advance.

3 Answers 3

2

Like wRAR said, once you have it as a python dict, it should be as simple as:

[x['email'] for x in l.itervalues()]
Sign up to request clarification or add additional context in comments.

Comments

1

Assuming you're converted you JSON string to a python dict (see loads()):

>>> from json import loads
>>> myJSON = loads(somejsonstring)
>>> emails = [a[x]['email'] for x in a]
>>> emails
['[email protected]', '[email protected]']

Or even better, use itervalues() as Luke mentioned.

Comments

0

Just do json.loads and process the resulting dict as usual. There is nothing JSON-specific here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.