-1

I have a json response from backend like:

JSON:

[
  ["Bondi Beach",-33.890542,151.274856,4],
  ["Coogee Beach",-33.923036,151.259052,5],
  ["Cronulla Beach",-34.028249,151.157507,3],
  ["Manly Beach",-33.80010128657071,151.28747820854187,2],
  ["Maroubra Beach",-33.950198,151.259302,1]
]

How can I parse it to an array like:

[
  ['Bondi Beach', -33.890542, 151.274856, 4],
  ['Coogee Beach', -33.923036, 151.259052, 5],
  ['Cronulla Beach', -34.028249, 151.157507, 3],
  ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
  ['Maroubra Beach', -33.950198, 151.259302, 1]
]
Kevin B
  • 94,570
  • 16
  • 163
  • 180
Spacex
  • 37
  • 4
  • 1
    Er, isn't it already in that format? I don't see the difference – CertainPerformance Mar 30 '18 at 18:52
  • nope its due to copy paste its json string first one @CertainPerformance – Spacex Mar 30 '18 at 18:55
  • 1
    Both are in the same format. Parsing it with the standard JSON.parse method will work. If it doesn't, your problem is somewhere else. (maybe you don't need to JSON.parse it at all, and instead can just use it.) – Kevin B Mar 30 '18 at 18:55

1 Answers1

0

You can use JSON.parse(array);

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

SeanMC
  • 1,960
  • 1
  • 22
  • 33