Reputation: 27
//Original array
var multipleBraceArray = "[
[
[-74.026675, 40.683935],
[-74.026675, 40.877483],
[-73.910408, 40.877483],
[-73.910408, 40.683935]
]
]";
//This is the output I am looking for:
var singleBraceArray = [
[-74.026675, 40.683935],
[-74.026675, 40.877483],
[-73.910408, 40.877483],
[-73.910408, 40.683935]
];
Upvotes: 0
Views: 94
Reputation: 2745
You have a couple errors:
\
character to signal a line-endArray
in a String
, not an Array
.Try using this instead:
var arr =JSON.parse("[[[-74.026675, 40.683935],[-74.026675, 40.877483],[-73.910408, 40.877483],[-73.910408, 40.683935]]]");
Upvotes: 0
Reputation: 16576
You're just looking for the first element of your multipleBraceArray
var multipleBraceArray = [[[-74.026675, 40.683935], [-74.026675, 40.877483], [-73.910408, 40.877483], [-73.910408, 40.683935]]];
var singleBraceArray = multipleBraceArray[0];
console.log(singleBraceArray);
Upvotes: 1