I am trying to get a value from json by using the JSON.parse
function. My json response is given below:
{
"rows": 10,
"os": "0",
"page": "1",
"total": "122",
"projects": {
"P143841": {
"id": "P143841",
"locations": [{
"geoLocId": "0002220957",
"latitude": "3.866667",
"longitude": "11.516667"
}],
}
}
}
I am able to get the value 10 if I do JSON.parse(obj.rows)
but if I assign the rows to a variable say var value = rows
and then I pass it to the JSON.parse(obj.value)
function I got undefined
.
P.S. I won't be knowing the names of the response parameters, i.e. i won't know if it will be rows
or os
quoting from the above example. I will be retrieving them from a database. If I perform the code below:
for (var i=0;i<length;i++) {
var value = responseParam_array[i];
console.log(obj.value);
}
I get the output but any help will be much appreciated.