我有以下JSON:
[{"Start":{}},{"Driving route":{}},{"Lunch-Rest Break":{}},{"Break":{}},{"Waiting":{}},{"End":{}}]
如何插入“1/8/2014”和“1/9/2014”等数据作为键“开始”的值,以便JSON看起来像:
[{"Start":{"1/8/2014","1/9/2014"}},{"Driving route":{}},{"Lunch-Rest Break":{}},{"Break":{}},{"Waiting":{}},{"End":{}}]
答案 0 :(得分:0)
例如这样?
$json_string = '[{"Start":{}},{"Driving route":{}},{"Lunch-Rest Break":{}},{"Break":{}},{"Waiting":{}},{"End":{}}]';
$x = json_decode($json_string,true);
$x[0]['Start'] = array("1/8/2014","1/9/2014");
$return_json = json_encode($x);
print $return_json;