How to create a json like object in javascript
means:
My object look like
var abc = [{ lat: 17.3753, lag: 78.4744, count: 4 }, { lat: 17.3754, lng: 78.4744, count: 1 }]
i tried with
var feedbackData = [];
for (index in dataCollection.collection) {
feedbackData.push({
lat: index.split('~')[0],
lag: index.split('~')[1],
count: dataCollection.item(index)
});
}
then i am sending like this JSON.stringify(feedbackData) this is not working.
how to create a object like that.
Please help
thanks in advance
for(.. in ..)loop. Try usingfor (var i = 0; i < dataCollection.collection.length; i++){...}latandlagorlatandlng? Your data seems to be inconsistent. I suspect a typo in the field names.