Add two JSON s in Javascript : I have two JSON s, I want to add two JSON s in Javascript,

JSON A :- 

    {
    
    	"data": [{
    		"id": 1,
    		"subgroup": "1",
    		"power": "2",
    		"grp": "1"
    	}, {
    		"id": 1,
    		"subgroup": "1",
    		"power": "1",
    		"grp": "1"
    	}, {
    		"id": 2,
    		"subgroup": "1",
    		"power": "1",
    		"grp": "2"
    	}, {
    		"id": 3,
    		"subgroup": "2",
    		"power": "1",
    		"grp": "2"
    	}, {
    		"id": 4,
    		"subgroup": "1",
    		"power": "1",
    		"grp": "3"
    	}, {
    		"id": 5,
    		"subgroup": "2",
    		"power": "1",
    		"grp": "2"
    	}, {
    		"id": 6,
    		"subgroup": "2",
    		"power": "1",
    		"grp": "1"
    	}, {
    		"id": 7,
    		"subgroup": "1",
    		"power": "1",
    		"grp": "4"
    	}, {
    		"id": 1,
    		"subgroup": "3",
    		"power": "2",
    		"grp": "4"
    	}
    
    }
    
    
    
    JSON B :- 
    
    {
    
    	"data": [{
    		"id": 1,
    		"subgroup": "3",
    		"power": "2",
    		"grp": "4"
    	}, {
    		"id": 1,
    		"subgroup": "4",
    		"power": "1",
    		"grp": "3"
    	}
    
    }


Key names are similar in JSON A and JSON B . We can see, `subgroup 3` and `subgroup 4` are only present in `grp 4` and `grp 3` respectively (look into JSON B). I want to add each `subgroup` from JSON B into each `grp` in JSON A (except the `grp` s where those `subgroup` s are already present. Like in JSON A there is an entry with `subgroup 3` and `grp 4`, we will skip that.). Value of `Id`, `power` will be similar respectively. So, we want to add `subgroup 3` in the `grp 1, 2, 3` and add `subgroup 4` in the `group 1, 2, 4` . For `subgroup 3`, `power` and `id` value will be `2, 1` respectively and for `subgroup 4`, `power` and `id` value will be `1, 1` respectively.

Final JSON A output should be, 



    {
    
    	"data": [{
    		"id": 1,
    		"subgroup": "1",
    		"power": "2",
    		"grp": "1"
    	}, {
    		"id": 1,
    		"subgroup": "1",
    		"power": "1",
    		"grp": "1"
    	}, {
    		"id": 2,
    		"subgroup": "1",
    		"power": "1",
    		"grp": "2"
    	}, {
    		"id": 3,
    		"subgroup": "2",
    		"power": "1",
    		"grp": "2"
    	}, {
    		"id": 4,
    		"subgroup": "1",
    		"power": "1",
    		"grp": "3"
    	}, {
    		"id": 5,
    		"subgroup": "2",
    		"power": "1",
    		"grp": "2"
    	}, {
    		"id": 6,
    		"subgroup": "2",
    		"power": "1",
    		"grp": "1"
    	}, {
    		"id": 7,
    		"subgroup": "1",
    		"power": "1",
    		"grp": "4"
    	}, {
    		"id": 1,
    		"subgroup": "3",
    		"power": "2",
    		"grp": "4"
    	}, {
    		"id": 1,
    		"subgroup": "3",
    		"power": "2",
    		"grp": "1"
    	}, {
    		"id": 1,
    		"subgroup": "3",
    		"power": "2",
    		"grp": "2"
    	}, {
    		"id": 1,
    		"subgroup": "3",
    		"power": "2",
    		"grp": "3"
    	}, {
    		"id": 1,
    		"subgroup": "4",
    		"power": "1",
    		"grp": "1"
    	}, {
    		"id": 1,
    		"subgroup": "4",
    		"power": "1",
    		"grp": "2"
    	}, {
    		"id": 1,
    		"subgroup": "4",
    		"power": "1",
    		"grp": "4"
    	}
    
    }