下の画像に示す JSON があります。0
アンダーアイテム というオブジェクトがあります。
アイテム内の属性を取得したい。jQuery または Javascript でアクセスするにはどうすればよいですか?
これは私がこれまでに持っているものです:
jQuery.getJSON('http://localhost/magento/js/primitives/js/SpaceTreeRegion.json',
function(jsonData) {
jQuery.each(jsonData, function(currentRegionNode, jsonData) {
alert(jsonData.items.product_name);
});
});
このコードはエラーを返します:jsonData.items.value is undefined
JSON は次のようになります。
[
{
"category_id": "Clothes",
"Items": [
{
"product_id": 1,
"price": 50,
"product_name": "Shirts"
},
{
"product_id": 2,
"price": 60,
"product_name": "T-Shirt"
}
]
}
]
オブジェクト内のproduct_id
およびprice
for product_name
eachへのアクセスが必要です。items