-3

I know this question appeared already some times but the answers did not hep me. I got a json string like this:

var jsonData = {
"target1": [
{"x":"222",
"y":"333",
"WPtext":"go right"},
{"x":"444",
"y":"444",
"WPtext":"go left"}
],
"target2": [
 {"x":"111",
 "y":"123",
"WPtext":"turn left"}
]
};

var waypoints = JSON.parse(jsonData);

The last statement throws the error: unexpected token o I'm not able to figure out whats wrong here, any help is appreciated, thank you,

Chris

Chris
  • 73
  • 1
  • 8

1 Answers1

-1

Thanks guys for the quick reply - meanwhile I figured it out also: it should be: var jsonData = '{[ ..... ]}' Ths single quotes around the whole string was missing.

Chris
  • 73
  • 1
  • 8
  • If you already have the object, why would you make it into the string and then parse it back into the object it already was? –  Dec 19 '15 at 17:09