Javascript – How to print JSON data in console.log

arraysjavascriptjson

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

Best Answer

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']);