I have some JSON shown in the image below. There is an object called 0 under items.
I want to get the attributes inside items. How can I access it with jQuery or Javascript?

This is what I have so far:
jQuery.getJSON('http://localhost/magento/js/primitives/js/SpaceTreeRegion.json',
function(jsonData) {
jQuery.each(jsonData, function(currentRegionNode, jsonData) {
alert(jsonData.items.product_name);
});
});
This code gives an error: jsonData.items.value is undefined
The JSON is like this:
[
{
"category_id": "Clothes",
"Items": [
{
"product_id": 1,
"price": 50,
"product_name": "Shirts"
},
{
"product_id": 2,
"price": 60,
"product_name": "T-Shirt"
}
]
}
]
I want access to product_id,price and product_name for each items in an Object.
try this code
jQuery.getJSON('your json url', function(yourJsonData) {
jQuery.each(yourJsonData[0].Items, function(key, customData) {
alert(customData.product_name);
});
});
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