我有以下对象:
var arr ={
{"id":{"id":"1059","department_id":4476,"location_id":42}},
{"id":"1060","department_id":75,"location_id":42}},
{"id":"178","department_id":75,"location_id":42}
};
我需要将它包装在父对象中,以进行以下操作:
var new_arr =
employees: {[
{"id":{"id":"1059","department_id":4476,"location_id":42}},
{"id":"1060","department_id":75,"location_id":42}},
{"id":"178","department_id":75,"location_id":42}
]};
有谁知道我怎么能这样做?
答案 0 :(得分:0)
你的意思是
var arr =[
{"id":{"id":"1059","department_id":4476,"location_id":42}},
{"id":{"id":"1060","department_id":75,"location_id":42}},
{"id":{"id":"178","department_id":75,"location_id":42}}
];
var employees = {employees:arr};
console.log(employees);