Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  13] [ 6]  / answers: 1 / hits: 67188  / 7 Years ago, fri, february 17, 2017, 12:00:00

I have JSON stringify data like this :



[{availability_id:109465,date:2017-02-21,price:430000},{availability_id:109466,date:2017-02-22,price:430000},{availability_id:109467,date:2017-02-23,price:430000}]


I want to get only price value of that data. I have tried this way but it doesn't work.



var stringify = JSON.stringify(values);

for(var i = 0; i < stringify.length; i++)
{
alert(stringify[i]['price']);
}


How could I to do that ?


More From » json

 Answers
20

This code will only fetch the price details.



var obj = '[{availability_id:109465,date:2017-02-21,price:430000},{availability_id:109466,date:2017-02-22,price:430000},{availability_id:109467,date:2017-02-23,price:430000}]';
var stringify = JSON.parse(obj);
for (var i = 0; i < stringify.length; i++) {
console.log(stringify[i]['price']);
}

[#58900] Wednesday, February 15, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jennie

Total Points: 593
Total Questions: 102
Total Answers: 106

Location: Federated States of Micronesia
Member since Fri, Sep 16, 2022
2 Years ago
;