I would like to make a JSON tree from an array. My array is formed like that :
var arraySource = [];
arraySource.push({key : "fr", value: "france"});
arraySource.push({key : "es", value: "spain"});
//...
console.debug(arraySource);
I would like to make a json tree formed like that
var destJson = {
"fr" : "france",
"es" : "spain"
};
I don't see how to make this dynamically because to make it I must do
destJson.fr = "france"
but it is not possible because items in the array are dynamics
Any idea ? If you want to play I have made a jsfiddle: