下面是我的這些JSON字符串,我試圖添加jsons。我如何實現。如何我可以合併兩個以上的Json字符串在PHP
$json1 = {"properties":{"title":"test","labels":["JanActual","Jan","Goal"],"values":["0","10000","0"]}}
$json2 = {"key":"Rental","type":"bar","values":["0","10000","0"]}
$json3 = {"key":"Service","type":"bar","values":["189","30000","0"]}
我想用它來合併它們和我期待輸出像下面
{
"properties":{
"title":"test",
"labels":[
"JanActual",
"Jan",
"Goal"
],
"values":[
"0",
"10000",
"0"
]
},
"data": [
{
"key":"Rental",
"type":"bar",
"values":[
"0",
"10000",
"0"
]
},
{
"key":"Service",
"type":"bar",
"values":[
"189",
"30000",
"0"
]
}
]
}
任何幫助嗎?
http://stackoverflow.com/questions/37174076/how-can-i-merge-two-json-strings-in-php –