Murtaza Khursheed Hussain Murtaza Khursheed Hussain - 1 year ago 102
jQuery Question

Merge two json/javascript arrays in to one array

I have two json arrays like

var json1 = [{id:1, name: 'xxx' ...}]
var json2 = [{id:2, name: 'xyz' ...}]

I want them merge in to single arrays

var finalObj = [{id:1, name: 'xxx' ...},{id:2, name: 'xyz' ...}]


Answer Source

You want the concat method.

var finalObj = json1.concat(json2);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download