Link to home
Start Free TrialLog in
Avatar of Moti Mashiah
Moti MashiahFlag for Canada

asked on

Javascript/Json

Hi Guys,

I would like to get the property names from a Javascript object to build a table dynamically. Example:

var data = [{
        Name: "xxxx",
        Last: "bbbbb"
                },
{
        Name: "ddddd",
        Last: "sssss"
}]

Now imagine this properties (Name , Last) come in different name from the database so how could I retrieve the property data from the json array with javascript.

Thank.
Avatar of HainKurt
HainKurt
Flag of Canada image

here

var data = [{
  Name: "xxxx",
  Last: "bbbbb"
}, {
  Name: "ddddd",
  Last: "sssss"
}];

alert("no of data: " + data.length);
alert("name of first data : " + data[0].Name);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jim Riddles
Jim Riddles
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Moti Mashiah

ASKER

thank you this is exactly what I was looking for:

var keys = Object.keys(data[0]);