I have a JavaScript object {} with a bunch of values, one of the values is an array []. After converting to JSON will look something like this.
{
"header-name": "",
"header-role": "",
"header-phone": "",
"header-website": "",
"header-email": "",
"header-location": "",
"exp-one": "ssfsdf",
"exp-two": "sdfsdf",
"exp-three": "",
"exp-four": "",
"exp-five": "",
"exp-six": "",
"exp-sub": [
"1",
"2",
"3",
"4",
"5"
]
}
I am able to loop through the JSON using var result = $.parseJSON(data); $.each(result, function(k, v) {});
What i am trying to do is also loop over that array that sits in the object "exp-sub", something like.
$.each(result, function(k, v) {
if (v == "exp-sub"){
$.each(k, function(key, val) {
//loop over array, this doesn't work though
}
}
});
Have tried with a for loop also but does not work either, any help will be appreciated thanks.
if (k == "exp-sub")instead ofif (v == "exp-sub")