Single quotes are allowed in JSON?

Asked

Viewed 1,768 times

4

I can represent a JSON object this way?

{
    'helloWorld': true
}

2 answers

4

No, only double quotes are allowed in JSON. The question example generates an invalid object as it can be tested in the link: http://jsonlint.com/

The right thing would be:

{
    "helloWorld": true
}

Note that the property name is required to be in double quotes, so the following notation is also invalid:

{
    helloWorld: true
}

3


Browser other questions tagged

You are not signed in. Login or sign up in order to post.