Mincho Minchev
Mincho Minchev

Reputation: 222

Are there any rules about quotes in JSON strings?

What do you think is a correct JSON string?

Some of the JSON visualization WEB tools that i use(such as http://jsonformatter.curiousconcept.com/ and http://chris.photobooks.com/json/default.htm) says that strings in JSON should be wrapped in double quotes.

enter image description here

enter image description here

I'm trying to find a rule or any kind of information that proofs this statement as correct but without success.

As we all know javascript does not care what kind of a quotes we use for strings (single or double) then why there is a rule in JSON's ?? I use JSON's alot and never had any problems in browsers caused by this rule.

If any of you knows why is this statement true please share it.
I will be very grateful.

Тhanks!

Upvotes: 3

Views: 1100

Answers (2)

Pratik Bhoir
Pratik Bhoir

Reputation: 2144

Just for a quick help over here, i think you must use double quotes. Use " instead of '

{"Test":"1"}

Upvotes: 0

mpm
mpm

Reputation: 20155

What do you think is a correct JSON string?

spec is here :

http://www.json.org/

spec says strings are quoted with double quotes, end of story.

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.

Upvotes: 6

Related Questions