My unique code snippet
Retrieve data = Array[2] :
0:object
id : "1" lat : "76.23" long:"21.92"
1:object
id:"2" lat:"10.23" long:"12.92"
var newCoords=[];
for(_i = 0; _i < retrieve_data.length; _i++)
{
var tmp = retrieve_data[_i];
var coordinates = [retrieve_data[_i]['lat'], retrieve_data[_i]['long']];
newCoords[tmp.id] = JSON.stringify(coordinates);
}
console.log(newCoords);
The result stored in newCoords is -
[1: "["76.2350","21.9253"]", 3: "["10.5650","21.3653"]", 6: "["60.5650","55.3653"]"]
this represents a JSON string
However, I am looking to format it as follows - {"1": [76.235,21.9253], "3": [10.565,21.3653], "6": [60.565,55.3653]}
Is there a solution to achieve this formatting?