Udit Udit - 1 year ago 94
JSON Question

How can I merge two json objects in same array by Id in another array?

I have a a big json array and have many objects and arrays inside it.
I want to merge two types of objects together.

For example : 1-10 stands for froms and
11-20 stands for Tos
So I want to merge Ṭos and froms and instead of showing them 1-20. I want to show 1-11, 2-12 and respectively.
How can I achieve this in angularJs.

Answer Source

you can use simple javascript to do this.

Iterate halfway through the originalArray using an index variable and push elements from both the ranges at the same time in a new array.

var newArray = [];
for (var i=0; i<10; i++){

I've assumed 20 as the original array length from your example. You can always use array's length property to calculate required values.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download