Anonymous
Anonymous

Reputation: 121

How to correctly set up a object in JSON in JavaScript?

I want to map a key "coordinate" to an object with two key-value pairs which are a key of "latitude" mapping to the integer 50 and a key "longitude" mapping to the integer 60.

"coordinate" : [{
    "latitude": 50, "longitude": 60
}]

My question is this the correct way to set up an object in JSON in JavaScript because I keep getting error or typo at "coordinate"?

Upvotes: 0

Views: 47

Answers (1)

Prasanna Brabourame
Prasanna Brabourame

Reputation: 847

You can make use of the below code to initialize the key value pair in object

var sampleObject = {"coordinate" : [{
    "latitude": 50, "longitude": 60
}]}

console.log(sampleObject)

Upvotes: 1

Related Questions