user1926138
user1926138

Reputation: 1514

create a json like object in javascript

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

Upvotes: 0

Views: 115

Answers (1)

Erik Christianson
Erik Christianson

Reputation: 507

JavaScript objects already are JSON objects (they were the inspiration for JSON objects). The array of the object you have already contains two JSON objects.

Upvotes: 1

Related Questions