[Twisted-web] small json improvements

Jp Calderone exarkun at divmod.com
Sun Sep 4 15:13:53 MDT 2005

On Sun, 4 Sep 2005 19:52:25 +0200, Eric Faurot <eric.faurot at gmail.com> wrote:
>This patch improves json tests and allow strings to be serialized
>as strings (as one would expect). 

This will break for strings containing ASCII control bytes (pretty much anything with ordinal value less than 32).  It will also break for strings containing bytes above 127.  If Python byte strings are supported, it should be in an 8-bit clean manner.  The one possible alternative to this I'm considering is to treat them as ASCII-encoded character strings, decode them as such, and then apply the unicode serialization rules to the result.

Unicode serialization support is, of course, incomplete.

>The raw class can be used to generate unquoted text (for token, statements, 

Why add support to json.serialize() for this?  Why not just not use json.serialize()?  The goal of json is to pass data around, not executable code.


More information about the Twisted-web mailing list