I need to convert a JavaScript object of one type:
object1: [{"a":"value1", "b":"value2", "c":"value3"}, {"d":"value4","e":"value5","f":"value6"}]
To another type of object:
object2 : {"value1":["value1", "value2", "value3"], "value4":["value4","value5","value6"]}
I tried to convert it using this function:
function toObject(arr) {
var rv = {};
for (var i = 0; i < arr.length; ++i) {
rv[i] = arr[i];
}
return rv;
}
but I'm getting numerical indexes ([0], [1]) instead of "value1" and "value4". Could you please give me some hint how can I do the conversion from object1 to object2. Thanks.
"value_"strings, or unless you know that the"a", "b", "c", etc...keys will always be every three letters in the alphabet.[3,3]to get your resulting structure.