Knowledge Walls
John Peter
Pune, Maharashtra, India
How to merge-join-concat JSON in Javascript or Jquery?
45236 Views
Concat Two Array of JSON using JAVASCRIPT 
Example 1

var jsonObjectA = [{"name":"john"},{"age":"12"}];
var jsonObjectB = {"sex":"male"};

// concat is a array object function. here concating json and array
jsonObjectA.concat(jsonObjectB);


Example 2

var jsonObjectA = [{"name":"john"},{"age":"12"}];
var jsonObjectB = [{"sex":"male"},{"zip","23343"}];

// concat is a array object function. Here concating array and array
jsonObjectA.concat(jsonObjectB);


Demo
Concat Key value based JSON using JQuery 
Example

var json1 = {"name":"john","age":"12"};
var json2 = {"member":"true"};
document.write(JSON.stringify($.extend(false,{},json1,json2)));


Output
{"name":"john","age":"12","member":"true"}


Demo
http://www.knowledgewalls.com/realtimejqueryeditor/Concat-Key-value-based-JSON-using-JQuery

Previous Topics
Previous lessons of current book.
Computer software engineer articles of One day One Thing to Know
Best Lessons of "One day One Thing to Know"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details