Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm afraid there's no way to achieve this automatically within the simplejson library.</p> <p>The scanner and decoder in simplejson are designed to produce unicode text. To do this, the library uses a function called <code>c_scanstring</code> (if it's available, for speed), or <code>py_scanstring</code> if the C version is not available. The <code>scanstring</code> function is called several times by nearly every routine that simplejson has for decoding a structure that might contain text. You'd have to either monkeypatch the <code>scanstring</code> value in simplejson.decoder, or subclass <code>JSONDecoder</code> and provide pretty much your own entire implementation of anything that might contain text.</p> <p>The reason that simplejson outputs unicode, however, is that the <a href="http://www.json.org/" rel="noreferrer">json spec</a> specifically mentions that "A string is a collection of zero or more Unicode characters"... support for unicode is assumed as part of the format itself. Simplejson's <code>scanstring</code> implementation goes so far as to scan and interpret unicode escapes (even error-checking for malformed multi-byte charset representations), so the only way it can reliably return the value to you is as unicode.</p> <p>If you have an aged library that needs an <code>str</code>, I recommend you either laboriously search the nested data structure after parsing (which I acknowledge is what you explicitly said you wanted to avoid... sorry), or perhaps wrap your libraries in some sort of facade where you can massage the input parameters at a more granular level. The second approach might be more manageable than the first if your data structures are indeed deeply nested.</p>
    singulars
    1. This table or related slice is empty.
    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.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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