The function below looks like right but it works incorrectly
$.when(
    $.getJSON('compare/As_edit.json'), $.getJSON('compare/As_old.json'))
    .then(function (a,b) {
        //return $.extend(a, b);
        console.log($.extend(a, b));
    })
In console log I see:
Object {text: "As", icon: "icons/tree.png", children: Array[1]}
While it should be "children: Array2"
My files look like:
file1
{
  "text": "As",
  "icon": "icons/tree.png",
  "children": [
    {
      "text": "Class1",
      "children": [
        {
          "text": "Intern1",
          "-ORDER": "2",
          "children": [
            {
              "name": "--TRT",
              "text": "Name of Intern"
            }
          ]
        },
        {
          "text": "Intern2",
          "-ORDER": "2",
          "children": [
            {
              "name": "--TRT",
              "text": "Name of Intern"
            }
          ]
        }
      ]
    }
  ]
}
file2
{
  "text": "As",
  "icon": "icons/tree.png",
  "children": [
    {
      "text": "Class2",
      "children": [
        {
          "text": "Intern3",
          "-ORDER": "2",
          "children": [
            {
              "name": "--TRT",
              "text": "Name of Intern"
            }
          ]
        },
        {
          "text": "Intern4",
          "-ORDER": "2",
          "children": [
            {
              "name": "--TRT",
              "text": "Name of Intern"
            }
          ]
        }
      ]
    }
  ]
}
and in output I want to see
{
  "text": "As",
  "icon": "icons/tree.png",
  "children": [
    {
      "text": "Class1",
      "children": [
        {
          "text": "Intern1",
          "-ORDER": "2",
          "children": [
            {
              "name": "--TRT",
              "text": "Name of Intern"
            }
          ]
        },
        {
          "text": "Intern2",
          "-ORDER": "2",
          "children": [
            {
              "name": "--TRT",
              "text": "Name of Intern"
            }
          ]
        }
      ]
    },
    {
      "text": "Class2",
      "children": [
        {
          "text": "Intern3",
          "-ORDER": "2",
          "children": [
            {
              "name": "--TRT",
              "text": "Name of Intern"
            }
          ]
        },
        {
          "text": "Intern4",
          "-ORDER": "2",
          "children": [
            {
              "name": "--TRT",
              "text": "Name of Intern"
            }
          ]
        }
      ]
    }
  ]
}
But I am only getting output from the object in file2 What's wrong?
this is a fiddle example
after checked reference on Merge 2 arrays of objects, I have used next code
 $.when(
        $.getJSON('compare/Astella_edit.json'), $.getJSON('compare/Astella_old.json'))
        .then(function (a,b) {
            var arr3 = [];
            for (var i in a) {
                var shared = false;
                for (var j in b)
                    if (b[j].children == a[i].children) {
                        console.log('['+ (b[j].children == a[i].children) +']');
                        shared = true;
                        break;
                    }
                if (!shared) arr3.push(a[i])
            }
            arr3 = arr3.concat(b);
            console.log(arr3);
            //return arr3;
        })
and it is merged to me almost correct
[Object, Object, "success", Object]
so the first object is file1, second is file2
what is "success" mean in generated JSON and Where is the third object coming from?
 
     
    