Create One dimensional array JSON JavaScript
- In this demo we will create One dimensional array JSON JavaScript using given JSON object as below:
[ { "ric": "ADAG.DE", "sedol": "5653487", "quantity": 107479, "activityQuantity": null, "businessDate": 20141023 }, { "ric": "ADAG.DE", "sedol": "BBJPFY1", "quantity": 2758, "activityQuantity": null, "businessDate": 20141023 }, { "ric": "ADAG.DE", "sedol": "5653487", "quantity": 107479, "activityQuantity": null, "businessDate": 20141023 }, { "ric": "BDAG.DE", "sedol": "5653487", "quantity": 107479, "activityQuantity": null, "businessDate": 20141023 }, { "ric": "BDAG.DE", "sedol": "5653487", "quantity": 107479, "activityQuantity": null, "businessDate": 20141023 } ];
- Final JSON out put with one dimensional value array with key as below:
[ { "key": "ADAG.DE", "values": [ { "ric": "ADAG.DE", "sedol": "5653487", "quantity": 107479, "activityQuantity": null, "businessDate": 20141023 }, { "ric": "ADAG.DE", "sedol": "BBJPFY1", "quantity": 2758, "activityQuantity": null, "businessDate": 20141023 }, { "ric": "ADAG.DE", "sedol": "5653487", "quantity": 107479, "activityQuantity": null, "businessDate": 20141023 } ] }, { "key": "BDAG.DE", "values": [ { "ric": "BDAG.DE", "sedol": "5653487", "quantity": 107479, "activityQuantity": null, "businessDate": 20141023 }, { "ric": "BDAG.DE", "sedol": "5653487", "quantity": 107479, "activityQuantity": null, "businessDate": 20141023 } ] } ]
- Output:
Run this code in Plunker here