Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://www.ietf.org/rfc/rfc4627.txt" rel="nofollow noreferrer">RFC 4627</a> states that JSON text SHALL be encoded in Unicode, whatever that means, and <a href="http://json.org/" rel="nofollow noreferrer">json.org</a> indicates that all characters be "unicode characters":</p> <ul> <li><p>Encoding</p> <p>JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.</p> <p>Since the first two characters of a JSON text will always be ASCII characters [RFC0020], it is possible to determine whether an octet stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking at the pattern of nulls in the first four octets.</p> <pre><code> 00 00 00 xx UTF-32BE 00 xx 00 xx UTF-16BE xx 00 00 00 UTF-32LE xx 00 xx 00 UTF-16LE xx xx xx xx UTF-8 </code></pre></li> </ul> <p>So if you're transferring JSON and saying that it's ISO-8859-1 then different JSON libraries may interpret the SHALL clause from the RFC that defines JSON in various ways, e.g. by encoding the replacement character or by sniffing the encoding. The best way if obviously to take this to whatever is outside your control and tell them to fix it :-)</p> <h2>Workarounds</h2> <p>One way to work around it is to create a servlet filter that removes all characters that are incompatible with both UTF-8 and ISO-8859-1 and replace them with JSON escapes:</p> <p>In the following fragment, replace 'é' with '\u00E9' so that any offending ISO-8859-1 character is safely transported in the 7-bits that are identical:</p> <p>Before: <code>{ "a" : "éte" }</code></p> <p>After: <code>{ "a" : "\u00E9te" }</code></p> <p>It's not as legible, but semantically speaking, it's the same, and any good JSON library should treat them identically.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload