Using json from Jython
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
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.
Unknown_dev
July 28, 2011
You can also check out the latest beta release of Jython which brings it up to 2.7 level with Python.
elec3647
March 27, 2014