答案 0 :(得分:0)
尝试这个
$existing_json='{"flight_id":181,"adults":"2","children":0,
"infants":0,"total":240,"departure":"16:5","passangers_number":0,
"passengers_id":178}';
$add_array=["id"=>178];
$arr=json_decode($existing_json);
$arr->passengers_id=$add_array;
$new_json=json_encode($arr);
预期产量
{"flight_id":181,"adults":"2","children":0,"infants":0,"total":240,"departure":"16:5","passangers_number":0,"passengers_id":{"id":178}}