"data":{
"2":{
"sub_category_id":"1",
"product":[
{
"sub_category_id":"1",
"product_id":"1",
"product_name":"American"
},
{
"sub_category_id":"1",
"product_id":"34",
"product_name":"Ausi Product"
}
]
},
"3":{
"sub_category_id":"2",
"product":{
"2":{
"sub_category_id":"2",
"product_id":"2",
"product_name":"Canadian"
}
}
}
}
我除外的结果:
"data":[
"2":{
"sub_category_id":"1",
"product":[
{
"sub_category_id":"1",
"product_id":"1",
"product_name":"American"
},
{
"sub_category_id":"1",
"product_id":"34",
"product_name":"Ausi Product"
}
]
},
"3":{
"sub_category_id":"2",
"product":[
"2":{
"sub_category_id":"2",
"product_id":"2",
"product_name":"Canadian"
}
]
]
即。我想在数据和产品之后找到[]。
答案 0 :(得分:-1)
您可以指示PHP json_decode()
函数将对象解析为关联数组。
$parsedJSON = json_decode($jsonString, /* $assoc = */ true)