From 4911c2f46721098dbeb00704cb7f802b2f5df95f Mon Sep 17 00:00:00 2001 From: giordano <domenico.giordano@cern.ch> Date: Thu, 19 Sep 2019 14:30:16 +0200 Subject: [PATCH] adding utility to check json differences --- common/json-differ.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 common/json-differ.py diff --git a/common/json-differ.py b/common/json-differ.py new file mode 100755 index 00000000..4905facc --- /dev/null +++ b/common/json-differ.py @@ -0,0 +1,21 @@ +#!/bin/python + +import sys +import json +from dictdiffer import diff + +json_a = json.load(open(sys.argv[1])) +json_b = json.load(open(sys.argv[2])) + +result = list(diff(json_a, json_b)) + +for entry in result: + if len(entry[2]) == 1: + print '\n\t %s :\n\t\t %s\t%s' % entry + else: + print '\n\t %s :\n\t\t %s\n\t\t\t%s\n\t\t\t%s' % (entry[0],entry[1],entry[2][0],entry[2][1]) + +exit(len(result)) + + + -- GitLab