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)?

daniel
  • 34,281
  • 39
  • 104
  • 158
  • 2
    for v in `logitems.values()`? `.itervalues()` for Py2. – Łukasz Rogalski Jan 14 '16 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: https://docs.python.org/3/library/json.html – Robert H Jan 14 '16 at 14:16

2 Answers2

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.

Community
  • 1
  • 1
earnshae
  • 169
  • 13
0

Right answer is in comment from Rogalski:

for v in logitems.values()? .itervalues() for Py2
daniel
  • 34,281
  • 39
  • 104
  • 158