From: Petri Lehtinen Date: Fri, 11 Sep 2009 19:22:34 +0000 (+0300) Subject: test/json-compare.py: Use json module from Python >=2.6 or simplejson X-Git-Tag: v1.0.3~2 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=jansson.git;a=commitdiff_plain;h=ab3764ed0a376633037599773010feeba64ec1a3 test/json-compare.py: Use json module from Python >=2.6 or simplejson Backported from master, commit 9d16ec755c9754fe1f79fe55ab719a7f8578ce37 --- diff --git a/test/json-compare.py b/test/json-compare.py index 1db93da..f91530e 100755 --- a/test/json-compare.py +++ b/test/json-compare.py @@ -5,8 +5,11 @@ # Jansson is free software; you can redistribute it and/or modify # it under the terms of the MIT license. See LICENSE for details. -import simplejson import sys +try: + import json +except ImportError: + import simplejson as json def load(filename): try: @@ -17,14 +20,14 @@ def load(filename): sys.exit(1) try: - json = simplejson.load(jsonfile) + jsondata = json.load(jsonfile) except ValueError, err: print "%s is malformed: %s" % (filename, err) sys.exit(1) finally: jsonfile.close() - return json + return jsondata def main(): if len(sys.argv) != 3: