Search code examples
pythonjsonpython-2.4

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. Is there a JSON library with a similar interface that is available for Python 2.4?


Solution

  • 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. You can just do:

    try:
        import json
    except ImportError:
        import simplejson as json