I’m appalled by the presence of highly-upvoted misinformation on such a highly-viewed question about a basic topic.
JSON strings cannot be quoted with single quotes. 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. 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.
Crockford’s and ECMA’s version even display the definition of a string using a pretty picture, which should make the point unambiguously clear:
The pretty picture also lists all of the legitimate escape sequences within a JSON string:
\ufollowed by four-hex-digits
Note that, contrary to the nonsense in some other answers here,
\' is never a valid escape sequence in a JSON string. It doesn’t need to be, because JSON strings are always double-quoted.
json_encode, or Python’s
json.dumps. If you’re using a language that doesn’t have such functionality built in, you can probably find a JSON parsing and encoding library to use. If you simply use language or library functions to convert things to and from JSON, you’ll never even need to know JSON’s escaping rules. This is what the misguided question asker here ought to have done.