Create One dimensional array JSON JavaScript

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:

2014-10-24 13_54_54-Create two dimensional array JSON JavaScript

 

Create One dimensional array JSON JavaScript

Run this code in Plunker here 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *