I have a result from an api call
var result = [
{
"m1": "State"
},
{
"m2": "Occupation"
},
{
"m3": "Qualification"
},
{
"m4": "Salary"
},
{
"m5": "Age"
},
{
"m6": "Status"
}
]
I want to be able to grab each value with $.each
loop but can’t seem to figure it out.
Here is my code so far.
var meta = $.parseJSON(result)
$.each(meta, function(index, value){
console.log(value)
})
The question is how can I log these values "State"
and "Occupation"
, "Qualification"
, "Salary"
, "Age"
and "Status"
?
I know one can’t do value."m"+index+1
Please point me the right way.
2
Answers
You could take a flat array of all values of nested objects.
If you are using js then it will be very easy to iterate values
I hope this will be helpful you just need to pass array to this function