Hello Everyone,

I'm writing a processor for Bitmessage messages and I am needing to
parse the following returned JSON string:

{u'inboxMessages': [{u'fromAddress':
u'BM-2DBYkhiBZCyrBa8J7gFRGrFRSGqtHgPtMvwQ', u'toAddress':
u'BM-2DC7SCTj2gzgrGgMvUCARdrfrsgLyz3iMyN3', u'read': 0, u'msgid':
u'36659a4453e12a085d8fbfeefc58da8fb23f38bfb0984c2983e0ddc31c776038',
u'receivedTime': u'1377986524', u'message':
u'dGVzdGluZyAxIDIgMw0KDQotLQ0KSm9obiBQZXJyeQ0KDQo=\n', u'encodingType':
2, u'subject': u'bWVzc2FnZSAx\n'}, {u'fromAddress':
u'BM-2DBYkhiBZCyrBa8J7gNBrngtgttHgPtMvwQ', u'toAddress':
u'BM-2DC7SCTj2gzgrGgMvUCARdCrfthyz3iMyN3', u'read': 0, u'msgid':
u'2ebe10c788ed47c6c122e3b43ae6642cb15077536c7056ed5088ab2d339c4630',
u'receivedTime': u'1377986557', u'message':
u'VGhpcyBpcyB0aGUgbmV4dCB0ZXN0DQoNCi0tDQpKb2huIFBlcnJ5DQoNCg==\n',
u'encodingType': 2, u'subject': u'dGVzdGluZyAzIDQgNQ==\n'},
{u'fromAddress': u'BM-2DBYkhithgyhyrBa8J7gNBrnSGqtHgPtMvwQ',
u'toAddress': u'BM-2DC7SCTj2gzgrtgtgMvUCARdCogLyz3iMyN3', u'read': 0,
u'msgid':
u'91dffd421c898aab0ffc43a363869a580abec6fa851aa6cf7cefe98263f96c81',
u'receivedTime': u'1377986599', u'message':
u'VGhpcyBpcyB0aGUgM3JkIHRlc3QNCg0hjj0NCkpvaG4gUGVycnkNCg0K\n',
u'encodingType': 2, u'subject': u'dGhpcyBpcyB0aGUgM3Jk\n'}]}

I tried using the following code:

data = json.loads(api.getAllInboxMessages) # This is the API call

for messageSender in data['inboxMessages']['fromAddress']
    print messageSender

For some reason (probably obvious reasons) isn't working. I'm trying to
loop through the JSON and return all of the fromAddress fields.

Can anyone offer suggestions?

Thanks,
Anthony
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to