Escapes string data for use in a JSON string.
8-bit and wider characters in input strings are neither escaped
nor utf-8 encoded by default. string_to_utf8 can be used safely
on the returned string to get a valid transport encoded JSON
string.
The characters U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH
SEPARATOR) are exceptions - they are encoded with \u escapes for
compatibility. The reason is that those characters are not allowed
in Javascript strings, so JSON parsers built in Javascript may
have trouble with them otherwise.