Reputation: 121
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
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