0

I get JSON from firebase (simplified):

logitems = {
u'-K7w56QCnpYI': { u'Date': 1452707179865.0618, u'Message': 'messagetest1' },
u'-K7w56safnpYI': { u'Date': 1452707179867.0618, u'Message': 'messagetest2' },
u'-FSDFSDddsfsI': { u'Date': 1452707179868.0618, u'Message': 'messagetest3' },
}

How can I iterate over the items (stored with keys instead in an array)?

2
  • 2
    for v in logitems.values()? .itervalues() for Py2. Commented Jan 14, 2016 at 14:13
  • 2
    with 2700+ rep, you should be able to formulate a proper question, or at the very least be able to search SO or Google. Look here: docs.python.org/3/library/json.html Commented Jan 14, 2016 at 14:16

2 Answers 2

1

I think you want to reference your items as shown in this post here.

Converting JSON String to Dictionary Not List

Then you can wrap your iteration in a for loop.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for selecting my answer I was convinced I would never get to comment on Stack Exchange :)
0

Right answer is in comment from Rogalski:

for v in logitems.values()? .itervalues() for Py2

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.