Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26978

Re: How do I access nested key/value pairs?

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: How do I access nested key/value pairs?
Date 2015-03-04 18:08 +0000
Organization A noiseless patient Spider
Message-ID <md7hnr$3qu$1@dont-email.me> (permalink)
References <3e102a71-73a4-41d5-811d-de9d0952f0cd@googlegroups.com>

Show all headers | View raw


On Wed, 04 Mar 2015 07:51:44 -0800, Masoom Tulsiani wrote:

> var hash =

hash seems to be an object containing three anonymous objects with no 
means of distinguishing them.

Trying to load this in javascript causes an error because each element of 
an object (including a nested object) requires an identifier.

Perhaps you mean hash to be an array?

You also have some unterminated string literals.

Once I fixed hash up to be a syntactically correct array of obs, the 
following code worked:

for (i=0; i<hash.length; i++) {
    if (hash[i].NAME) {
        console.log('hash['+i+'].NAME = '+hash[i].NAME);
        if (hash[i].NAME=='Feed.FeedName')
            for (p in hash[i].FIELDS)
                if (hash[i].FIELDS.hasOwnProperty(p))
                    console.log('hash['+i+'].FIELDS.'+p+' = '+
                                hash[i].FIELDS[p]);
    }
}


-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How do I access nested key/value pairs? Masoom Tulsiani <masoom.tulsiani@gmail.com> - 2015-03-04 07:51 -0800
  Re: How do I access nested key/value pairs? John Harris <niam@jghnorth.org.uk.invalid> - 2015-03-04 16:14 +0000
  Re: How do I access nested key/value pairs? Denis McMahon <denismfmcmahon@gmail.com> - 2015-03-04 18:08 +0000
    Re: How do I access nested key/value pairs? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-05 16:25 +0100
      Re: How do I access nested key/value pairs? John Harris <niam@jghnorth.org.uk.invalid> - 2015-03-06 10:26 +0000
        Re: How do I access nested key/value pairs? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-06 12:20 +0100
          Re: How do I access nested key/value pairs? John Harris <niam@jghnorth.org.uk.invalid> - 2015-03-06 20:18 +0000
  Re: How do I access nested key/value pairs? Scott Sauyet <scott.sauyet@gmail.com> - 2015-03-04 12:15 -0800
    Re: How do I access nested key/value pairs? Scott Sauyet <scott.sauyet@gmail.com> - 2015-03-04 12:17 -0800

csiph-web