4

I have following json in file mock.json. I am trying to load it via ajax call however, I am getting this error.

Error: Parse error on line 1:
{   id: 1,  name: 'My na
--^
Expecting 'STRING', '}', got 'undefined'

I used to jsonlint validator to validate json and getting above error. Whats wrong my json?

[{
    id: 1,
    name: 'My name',
    email: '[email protected]'
}]

1 Answer 1

7

The JSON standard describes properties as strings and strings need double quotes ".

A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.

So you need double quotes for properties and values as strings in your JSON.

[{
    "id": 1,
    "name": "My name",
    "email": "[email protected]"
}]
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.