JSON format in KnockoutJS

I am getting JSON format like below:

[
{
    "moduleName": null,
    "bundleKey": "title",
    "bundleValue": "Manage cost code",
    "id": 4,
    "createdBy": 0,
    "modifiedBy": 0,
    "createdDate": "0001-01-01T00:00:00",
    "modifiedDate": "0001-01-01T00:00:00",
    "rowVersion": null,
    "isDeleted": false
},
{
    "moduleName": null,
    "bundleKey": "name",
    "bundleValue": "steve",
    "id": 5,
    "createdBy": 0,
    "modifiedBy": 0,
    "createdDate": "0001-01-01T00:00:00",
    "modifiedDate": "0001-01-01T00:00:00",
    "rowVersion": null,
    "isDeleted": false
}]

I would like to format that as a key-value pair, like the following:

[{"title":"Manage cost code", "name":"steve"}]

Whether it is possible to format JSON like this.

Or is it possible to get data directly from a database in the format below?

I do not want to query the column name, only its values should be queried.

Answers


If you want to do it clientside, just use a simple reduce function

var src = [...];
var result = src.reduce( function(prev, current) {
    prev[current.bundleKey] = current.bundleValue;
    return prev;
}, {} );

Need Your Help

Maven configuration in IntelliJ yields authorization exception

maven intellij-idea

Backstory: I have a total of 30 minutes of maven usage experience, so it's safe to say I'm a newbie. I've successfully added a JUnit reference, but as soon as I tried adding the following, problems

How to draw a coreplot barchart with a huge y-Axis?

iphone ios core-plot

I am creating a small iPhone application using CorePlot. The graph consists of 10 bars. Unfortunately, the y-values might differ between 0 and 1 million, therefore I create my plotspace with a rather