2

Does JSON only support Unicode? It doesn't seem like encoding matters if this is the case. Won't all JSON then be unicode, and the Charset just a matter of storage?

2 Answers 2

10

From the RFC, "JSON text SHALL be encoded in Unicode." Unicode is really a character set, not an encoding, though. It also says the "default encoding is UTF-8." The same section explains how to distinguish between UTF-32BE, UTF-16BE, UTF-32LE, UTF-16LE, and UTF-8 based on the pattern of nulls.

In summary, use UTF-8 unless you have a strong reason to do otherwise. However, you can use a different Unicode encoding.

Sign up to request clarification or add additional context in comments.

2 Comments

@Stephen, thanks for the correction. I thought (incorrectly) that SHALL was equivalent to SHOULD. You're right that it's actually equivalent to MUST.
@Stephen, yes, I was aware of that RFC. But I didn't check it before answering. :)
0

Encoding would matter when you read or parse the JSON string to be sent in the response. So response encoding would come into play When reading a JSON data from request, you would need to make sure you have encoding set for that case as well.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.