0

I've got code.

{
 s: "ok",
 t: [1386493512, 1386493572, 1386493632, 1386493692],
 c: [42.1, 43.4, 44.3, 42.8]
}

Why it return code SyntaxError: JSON.parse: expected property name or '}' at line 2 column 4 of the JSON data

3
  • 2
    For starters that's not valid JSON. Property names have to be enclosed in double quotes. See json.org for more details... Commented Aug 10, 2015 at 18:24
  • 1
    "I've got code." Good. Where is that code? What JS is calling JSON.parse? Commented Aug 10, 2015 at 18:24
  • 2
    that's not json, that's javascript. in json, object keys MUST be quoted. Commented Aug 10, 2015 at 18:24

1 Answer 1

4

In javascript the keys are presumed to be strings so keys do not need to be in quotes, however in JSON they do. You should change your code to look like

{
 "s": "ok",
 "t": [1386493512, 1386493572, 1386493632, 1386493692],
 "c": [42.1, 43.4, 44.3, 42.8]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.