Using json from Jython

Posted on July 31, 2010. Filed under: Uncategorized | Tags: , , , , , |

I recently tried to use json from Jython. In CPython, there is a json module which is part of the standard library. However, this was only introduced in python 2.6. The most recent stable version of Jython is 2.5.1 however and it does not know a json module out of the box.

Fortunately, I came across jyson (http://opensource.xhaus.com/projects/show/jyson) which is a pure Java implementation of a json reader/writer. Although the code lives in its own name space, it seems that one can get the basic functionality (json.loads and json.dumps) equivalent to the CPython json module by doing:

import com.xhaus.jyson.JysonCodec as json

About these ads

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

2 Responses to “Using json from Jython”

RSS Feed for Andre Holzner's Blog Comments RSS Feed

Thanks for the tip, I have tried and worked, although that way of importing didnt work for me .. i tried

from com.xhaus.jyson import JysonCodec as json

and worked just fine.

You can also check out the latest beta release of Jython which brings it up to 2.7 level with Python.


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: