Note that, contrary to the nonsense in some other answers here, \' is never a valid escape sequence in a JSON string. The pretty picture also lists all of the legitimate escape sequences within a JSON string: This is not a theoretical issue, nor a matter of opinion as the accepted answer currently suggests any JSON parser in the real world will error out if you try to have it parse a single-quoted string.Ĭrockford's and ECMA's version even display the definition of a string using a pretty picture, which should make the point unambiguously clear: The various versions of the spec ( the original by Douglas Crockford, the ECMA version, and the IETF version) all state that strings must be quoted with double quotes. ![]() JSON strings cannot be quoted with single quotes. I'm appalled by the presence of highly-upvoted misinformation on such a highly-viewed question about a basic topic.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |