cannot jsonify dicts?!

0 views
Skip to first unread message

Jonathan LaCour

unread,
Aug 15, 2006, 2:45:21 PM8/15/06
to turbo...@googlegroups.com
I am trying to jsonify a simple dictionary like this:

>>> from turbojson.jsonify import jsonify
>>>
>>> d = {1:'one', 2:'two'}
>>> jsonify(d)
Traceback (most recent call last):
File "<console>", line 1, in ?
File "<string>", line 5, in jsonify
File "_speedups.pyx", line 376, in
_speedups.BaseDispatcher.__getitem__
File "/eggs/dispatch/interfaces.py", line 15, in __call__
NoApplicableMethods: (({1: 'one', 2: 'two'},), {})

Am I crazy, or should this work?

--
Jonathan LaCour
http://cleverdevil.org

Jorge Godoy

unread,
Aug 15, 2006, 2:52:27 PM8/15/06
to turbo...@googlegroups.com
Jonathan LaCour <jonatha...@cleverdevil.org> writes:

>>> from turbojson import jsonify


>>> d = {1:'one', 2:'two'}

>>> jsonify.encode(d)
'{"1": "one", "2": "two"}'
>>>


--
Jorge Godoy <jgo...@gmail.com>

Kevin Dangoor

unread,
Aug 15, 2006, 10:09:37 PM8/15/06
to turbo...@googlegroups.com

Which is to say use "encode" instead of "jsonify". simplejson knows
how to handle dicts directly, so it doesn't need the generic function.

Kevin

Reply all
Reply to author
Forward
0 new messages