Keerthi Vasan Keerthi Vasan - 2 months ago 5
JSON Question

Parse the JSON Object with Index or position instead of keyname using Jquery?

My Existing Code and Explanation

Working Fine, But I want to Create a template like Its should read JSON Data that Having keys in any name, I am Always reading data from JSON object in 2nd Position

Now I read the JSON that passed in the argument (data) inside that using the for loop extract single object in group, after that get the data using key(Module_Name).. I know the key(Module_Name) is always present in second position only, Now its Working Fine with keyname rather i want to fetch the data using position, that also used as template in my other modules

/* render Screen Objects */
screenRenderer.displayScreens = function(data)
screenRenderer.renderLayout(function(cont, boo)
if (boo)


var buttons = "<button class='screen_button'>"+data[i].Module_Name+"</button>";


This is My Requirement, kindly awaiting suggestions, answers..
Thanks in Advance


You can use the function Object.keys(obj) to get all keys of an object as array, which you can access with an Index and than use the String you get to access the property.

So it could look like this:

var obj = data[i];
var keys = Object.keys(obj);
var result = obj[keys[1]];

Hope this is what you want.