简体   繁体   English

python 2.4的JSON模块?

[英]JSON module for python 2.4?

I'm accustomed to doing import json in Python 2.6, however I now need to write some code for Python 2.4. 我习惯于在Python 2.6中执行import json ,但是现在我需要为Python 2.4编写一些代码。 Is there a JSON library with a similar interface that is available for Python 2.4? 是否存在可用于Python 2.4且具有类似接口的JSON库?

Now, a few years later, simplejson does only support python 2.5+. 现在,几年后,simplejson仅支持python 2.5+。 No more simplejson for systems stuck on 2.4. 对于停留在2.4上的系统,没有更多的simplejson。 Even though it is not supported, you may find older packages on pypi. 即使不支持它,您也可以在pypi上找到较旧的软件包。 2.0.9 or 2.1.0 should work. 2.0.9或2.1.0应该有效。

pip install simplejson==2.1.0

(I could not comment on the chosen answer, but this just bit me hard, so it may be useful to others as well) (我无法评论所选的答案,但这使我很难受,因此对其他人也可能有用)

The json module in Python 2.6 is mostly the same as the simplejson third-party module, which is available for Python 2.4 as well. Python 2.6中的json模块几乎与simplejson第三方模块相同,后者也可用于Python 2.4。 You can just do: 您可以这样做:

try:
    import json
except ImportError:
    import simplejson as json

I needed to get this up on an old box with Python 2.4.3. 我需要在带有Python 2.4.3的旧盒子上安装它。 Used simplejson-1.7-py2.4.egg from here: 从这里使用了simplejson-1.7-py2.4.egg:

https://pypi.python.org/packages/2.4/s/simplejson/ https://pypi.python.org/packages/2.4/s/simplejson/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM