0

I've read through several other questions concerning this topic and they have brought me further, but not where I want to be just yet. I have a collection object which I alert with the following code:

alert(JSON.stringify(oResponse.Result, null, 4)); 

This gives me the following output (this is just a part):

{
    "@Object": "Collection/MessageCollection",
    "@Count": 20,
    "@Collection": [
        {
            "@Object": "Object/MessageListItem",
            "Folder": "INBOX",
            "Uid": 37445,
            "Subject": "NEW: Easily sync in-store and online inventory with Lightspeed POS",
            "MessageId": "<2c1434dc56f9506bf3c3ecd21ecf0de6023.20150916163348@mail69.suw11.mcdlv.net>",
            "Size": 71515,
            "TextSize": 28739,
            "InternalTimeStampInUTC": 1442421281,
            "ReceivedOrDateTimeStampInUTC": 1442421281,
            "TimeStampInUTC": 1442421281,
            "From": [
                {
                    "@Object": "Object/Email",
                    "DisplayName": "WooCommerce",
                    "Email": "mailers@woothemes.com"
                }
            ],
            "To": [
                {
                    "@Object": "Object/Email",
                    "DisplayName": "",
                    "Email": "info@xxx.nl"
                }

As you can probably see, there are emails in the collection object. I want to iterate over them and extract the 'Uid' and the 'From e-mail'. I tried this, but it gives me an undefined:

for(var item in oResponse.Result) {
        alert(item[0].Uid);     
    }

Anyone who can give me some advice? Thanks!

Sander
  • 449
  • 2
  • 5
  • 12
  • Looks like you want to iterate over the array in `@Collection`. Why do you iterate over `Result`? – Felix Kling Sep 16 '15 at 19:20
  • You're using the `for in` loop wrong, and you shouldn't use a `for in` loop at all. Just do a regular `for (var i=0; i – Bergi Sep 16 '15 at 19:21

0 Answers0