Encoding JSON in UTF-16 or UTF-32
As far as I can tell, yes, you can write the UTF-16 values directly. Support: the RFC paragraph you quoted explains how to escape arbitrary Unicode if you have decided to escape it. However, earlier in that same section, the RFC says
All Unicode characters may be placed within the quotation marks except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F).
Any character may be escaped. If the character is in the Basic Multilingual Plane (U+0000 through U+FFFF), then it may be represented as a six-character sequence...
(Emphasis added.)
To me, this says that only "
, \
and control characters must be escaped, and that any other Unicode characters may be placed as-is directly into the JSON text (in whatever UTF form you are using). It also says to me that even if you're encoding as UTF-8, you don't need to use the \uXXXX
form for any Unicode character other than "
, \
, and control characters.
(As an aside, this does make me wonder whether the \uXXXX
form is actually useful for anything other than control characters. As the other poster said, it probably comes down to what your JSON parser actually supports.)