Ok, it's done in svn with the obvious API (simple_json.loads/load),
which takes an optional encoding kwarg to specify what encoding to
expect input to be in. It must be an ASCII based encoding though,
something like UCS-2 needs to come in as unicode because that affects
more than strings. The encoder in 1.0 encodes as ASCII represented
as str instances by default (using \uXXXX escapes), you can turn that
off and get 0.1 behavior by passing "ensure_ascii=False", which will
give you either a str or unicode string as output based on the normal
Python str->unicode coercion rules.
I've version bumped to 1.0 because it's basically done other than
future performance tweaks and maybe a bugfix or two. It's already on
svn and in CheeseShop.
The advantages-by-design over json-py are:
1. MIT licensed
2. Correct and fully extensible encoder
3. Correct decoder with encoding options
4. Python 2.3 support
5. Probably faster (have not benchmarked at all)
The decoder does take advantage of some undocumented sre API, which
binds it to sre and CPython, but that's basically an academic
restriction in this context.
The tests are kinda lazy and require nose. It's just a big doctest
in simple_json/__init__.py.
-bob
On Dec 25, 2005, at 5:40 PM, Bob Ippolito wrote:
I'll have decoding in simple_json for 0.2. It's almost done...
need to hammer out a bug or three and write real tests.
-bob
On Dec 25, 2005, at 8:24 AM, Kevin Dangoor wrote:
OK. I wasn't aware of that. Feel free to add the json-py requirement
back in (or I'll do it when I get a chance).
Kevin
On 12/25/05, Jeff Watkins <[EMAIL PROTECTED]> wrote:
The new AjaxDataController expects all object data to arrive in JSON
format. I was using json-py to parse the incoming JSON data.
In keeping with the "One Way To Do It", I think whatever JSON
package
TurboGears supports, MUST encode and decode JSON formatted data.
Otherwise, developers will be forced to find an alternative solution
for JSON.
On 24 Dec, 2005, at 9:12 pm, Kevin Dangoor wrote:
At the moment, TurboGears doesn't actually have anything that
depends
on incoming JSON (that I'm aware of... CatWalk, perhaps?) You
can make
REST-style requests just fine without being able to decode JSON.
--
Jeff Watkins
http://newburyportion.com/
"Computers are like Old Testament gods; lots of rules and no mercy."
-- Joseph Campbell
--
Kevin Dangoor
Author of the Zesty News RSS newsreader
email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com