how to print json data in console.log


I cant access json data from javascript. Please help me how to access data from json data in javascript.

i have a json data like

{"success":true,"input_data":{"quantity-row_122":"1","price-row_122":" 35.1 "}}

i have tried console.log(data) but log print object object

success:function(data){
     console.log(data);
}

how to print console.log particular data? i need to print quantity-row_122 = 1 price-row_122 = 35.1


Answers:


console.log(JSON.stringify(data)) will do what you need. I'm assuming that you're using jQuery based on your code.

If you're wanting those two particular values, you can just access those and pass them to log.

console.log(data.input_data['quantity-row_122']); 
console.log(data.input_data['price-row_122']);