我有一个这样的 JSON:
var parse = [
{
"variation_id":"34",
"attributes":{
"attribute_pa_rozmiar":"m"
},
"image_src":"http://localhost/Fraise-WP/wp-content/uploads/2013/06/Jellyfish-300x300.jpg",
"image_link":"http://localhost/Fraise-WP/wp-content/uploads/2013/06/Jellyfish.jpg",
"image_title":"Jellyfish",
"price_html":"",
"availability_html":"<p class=\"stock \">10 w magazynie</p>",
"sku":"",
"weight":"4 kg",
"dimensions":"",
"min_qty":1,
"max_qty":"10",
"backorders_allowed":false,
"is_in_stock":true,
"is_downloadable":false,
"is_virtual":false,
"is_sold_individually":"no"
},
{
"variation_id":"33",
"attributes":{
"attribute_pa_rozmiar":"s"
},
"image_src":"http://localhost/Fraise-WP/wp-content/uploads/2013/06/Desert-300x300.jpg",
"image_link":"http://localhost/Fraise-WP/wp-content/uploads/2013/06/Desert.jpg",
"image_title":"Desert",
"price_html":"",
"availability_html":"<p class=\"stock \">5 w magazynie</p>",
"sku":"",
"weight":"4 kg",
"dimensions":"",
"min_qty":1,
"max_qty":"5",
"backorders_allowed":false,
"is_in_stock":true,
"is_downloadable":false,
"is_virtual":false,
"is_sold_individually":"no"
}
][
{
"variation_id":"34",
"attributes":{
"attribute_pa_rozmiar":"m"
},
"image_src":"http://localhost/Fraise-WP/wp-content/uploads/2013/06/Jellyfish-300x300.jpg",
"image_link":"http://localhost/Fraise-WP/wp-content/uploads/2013/06/Jellyfish.jpg",
"image_title":"Jellyfish",
"price_html":"",
"availability_html":"<p class=\"stock \">10 w magazynie</p>",
"sku":"",
"weight":"4 kg",
"dimensions":"",
"min_qty":1,
"max_qty":"10",
"backorders_allowed":false,
"is_in_stock":true,
"is_downloadable":false,
"is_virtual":false,
"is_sold_individually":"no"
},
{
"variation_id":"33",
"attributes":{
"attribute_pa_rozmiar":"s"
},
"image_src":"http://localhost/Fraise-WP/wp-content/uploads/2013/06/Desert-300x300.jpg",
"image_link":"http://localhost/Fraise-WP/wp-content/uploads/2013/06/Desert.jpg",
"image_title":"Desert",
"price_html":"",
"availability_html":"<p class=\"stock \">5 w magazynie</p>",
"sku":"",
"weight":"4 kg",
"dimensions":"",
"min_qty":1,
"max_qty":"5",
"backorders_allowed":false,
"is_in_stock":true,
"is_downloadable":false,
"is_virtual":false,
"is_sold_individually":"no"
}
]
我需要的是在里面运行搜索attributes
,查找这个对象是否有,例如。attribute_pa_rozmiar=m
并得到相应image_src
的 . 抱歉,JSON 如此臃肿,但这是我能把它弄出来的唯一方法。