我怎样才能得到这种格式:
{
"products": [
{
"id": 4,
"link": "/product.php?id_product=4",
"quantity": 1,
"priceByLine": "$185.00",
"name": "Orci hendrer...",
"price": "$185.00",
"idCombination": 0,
"hasAttributes": false,
"hasCustomizedDatas": false,
"customizedDatas":[
]
}, {
"id": 5,
"link": "/product.php?id_product=5",
"quantity": 1,
"priceByLine": "$215.00",
"name": "Semper rutru...",
"price": "$215.00",
"idCombination": 0,
"hasAttributes": false,
"hasCustomizedDatas": false,
"customizedDatas":[
]
}],
}
作为一个PHP数组?我试过了
$array[] = array('id'=>5, link => 'product.php?id_product=5' ... and so on)
但是当我用 JSON 编码时它不起作用。