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
The console. log(JSON. stringify(obj)) method can be useful for logging the object to the console as string, as long as the data in the object is JSON-safe.
The simplest way is using the Console log() method to log objects as JSON in JavaScript. The console. log() method called with an object or objects as arguments will display the object or objects.
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']);
I used '%j' option in console.log to print JSON objects
console.log("%j", jsonObj);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With