Appending data to JSON using javascript or jQuery.
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Looking for a approach to append a JSON string.

var js1 =[
  {"Name":"Fred",  "age":53  },
  {"Name":"Wilma",  "age":44  }
  ];

var js2 =[  {"Name":"Pebbles",  "age":7  } ];

Need to append js2 to js1 so that js1 now looks like:

var js1 =[
  {"Name":"Fred",  "age":53  },
  {"Name":"Wilma",  "age":44  },
  {"Name":"Pebbles",  "age":7  }
  ];
awarded to julianobs

Crowdsource coding tasks.

1 Solution


Just concatenate them like this:

js1 = js1.concat(js2);

Tell me if that's what you needed! =]