-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

3
  • 2
    jsonData is already an object so why you want to parse it? Commented Dec 19, 2015 at 12:55
  • Your JSON is already parsed Commented Dec 19, 2015 at 12:55
  • typeof jsonData is already object. Commented Dec 19, 2015 at 13:07

1 Answer 1

-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.

Sign up to request clarification or add additional context in comments.

1 Comment

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?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.