I have the following hash structure with nested key/value pairs.
How can I access a particular key and value pair. For Instance,I would like
to access FIELDS -> UNAME(key)
and FIELDS -> STRING (value) of the message with *OBJ_TYPE: FEED *
var hash =
{
{ OBJ_TYPE: 'RESULT',
NAME: 'Result.ResultName,
FIELDS:
{ UNAME: 'STRING',
DESC: 'STRING',
},
}
{ OBJ_TYPE: 'FEED', // Key is Obj_type and value is Feed
NAME: 'Feed.FeedName, // Key is name and value is Feed.FeedName
FIELDS:
{ UNAME: 'STRING',
DESC: 'STRING',
},
}
{ OBJ_TYPE: 'X',
NAME: 'X.XName,
FIELDS:
{ UNAME: 'STRING',
DESC: 'STRING',
},
}
}
*App.js*
var hash = { /*structure that I described above */};
for(var k in hash)
{
if(hash.hasOwnProperty(k) && k=="NAME" && hash[k]=="Feed.FeedName")
{
// I could do something like var fields = hash[k]=="FIELDS";
for(var eachField in fields){
console.log(eachField);
}
}
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/6209caf5-84eb-4373-92f6-0beb64046da6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.