test/json-compare.py: Use json module from Python >=2.6 or simplejson
Backported from master, commit 9d16ec755c
This commit is contained in:
parent
9cc6fbe580
commit
ab3764ed0a
@ -5,8 +5,11 @@
|
|||||||
# Jansson is free software; you can redistribute it and/or modify
|
# Jansson is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the MIT license. See LICENSE for details.
|
# it under the terms of the MIT license. See LICENSE for details.
|
||||||
|
|
||||||
import simplejson
|
|
||||||
import sys
|
import sys
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
except ImportError:
|
||||||
|
import simplejson as json
|
||||||
|
|
||||||
def load(filename):
|
def load(filename):
|
||||||
try:
|
try:
|
||||||
@ -17,14 +20,14 @@ def load(filename):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
json = simplejson.load(jsonfile)
|
jsondata = json.load(jsonfile)
|
||||||
except ValueError, err:
|
except ValueError, err:
|
||||||
print "%s is malformed: %s" % (filename, err)
|
print "%s is malformed: %s" % (filename, err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
finally:
|
finally:
|
||||||
jsonfile.close()
|
jsonfile.close()
|
||||||
|
|
||||||
return json
|
return jsondata
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
|
Loading…
Reference in New Issue
Block a user