[Tutor] Json encode and decode on Puython 2.4

Steven D'Aprano steve at pearwood.info
Thu Jan 17 00:15:43 CET 2013


On 17/01/13 08:15, Dotan Cohen wrote:
> Hi all, I'm just getting into porting some PHP scripts to Python. One
> issue that I'm having is that the scripts need to run on a host with
> Python 2.4 that has neither the json nor simplejson packages
> available. I figure that I'll have to include the loads() and dumps()
> functions in my application. Where might I find the source for these
> two functions? What would be the best way to include them?

Python 2.4 is no longer receiving security updates. If you're exposing a
web app on the Internet using Python 2.4, it's just a matter of time
before you're hacked.

Time to change hosting companies, methinks.

If it is a Centos or RedHat based Linux system, it will support simplejson.

[steve at ando /]$ sudo yum install simplejson
[sudo] password for steve:
[...extremely long output deleted...]

Installed:
   python-simplejson.i386 0:2.0.9-8.el5

Complete!
[steve at ando /]$ python2.4
Python 2.4.3 (#1, Jun 18 2012, 08:55:31)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
py> import simplejson
py> print simplejson
<module 'simplejson' from '/usr/lib/python2.4/site-packages/simplejson/__init__.pyc'>




-- 
Steven


More information about the Tutor mailing list