You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the two attached jsons (renamed to .txt to appease github…) trying to run jsondiff.diff on them returns a list.
In my applications I already previously loaded the jsons since I'm doing some processing on them before handling them over to jsondiff, and we need to use OrderedDict for that.
transcriptions:
In [1]: import json
In [2]: import jsondiff
In [3]: import collections
In [4]: with open('1.json') as f:
...: a = json.load(f, object_pairs_hook=collections.OrderedDict)
...:
In [5]: with open('2.json') as f:
...: b = json.load(f, object_pairs_hook=collections.OrderedDict)
...:
In [6]: type(jsondiff.diff(a, b))
Out[6]: list
In [7]: jsondiff.diff(a, b)
Out[7]:
[OrderedDict([('id', '/build/node-module-deps-6.1.0/2nd/example/files/bar.js'),
('source',
'module.exports = function (n) {\n return n * 100;\n};\n'),
('deps', OrderedDict()),
('file',
'/build/node-module-deps-6.1.0/2nd/example/files/bar.js')]),
OrderedDict([('id', '/build/node-module-deps-6.1.0/2nd/example/files/foo.js'),
('source',
"var bar = require('./bar');\n\nmodule.exports = function (n) {\n return n * 111 + bar(n);\n};\n"),
('deps',
OrderedDict([('./bar',
'/build/node-module-deps-6.1.0/2nd/example/files/bar.js')])),
('file',
'/build/node-module-deps-6.1.0/2nd/example/files/foo.js')]),
OrderedDict([('file',
'/build/node-module-deps-6.1.0/2nd/example/files/main.js'),
('id',
'/build/node-module-deps-6.1.0/2nd/example/files/main.js'),
('source',
"var foo = require('./foo');\nconsole.log('main: ' + foo(5));\n"),
('deps',
OrderedDict([('./foo',
'/build/node-module-deps-6.1.0/2nd/example/files/foo.js')])),
('entry', True)])]
In [8]:
Is this expected? I always saw dicts being returned by jsondiff, and also I can't spot anything in jsondiff's code that obviously returns a list out of itself.
With the two attached jsons (renamed to .txt to appease github…) trying to run jsondiff.diff on them returns a list.
In my applications I already previously loaded the jsons since I'm doing some processing on them before handling them over to jsondiff, and we need to use OrderedDict for that.
transcriptions:
Is this expected? I always saw dicts being returned by jsondiff, and also I can't spot anything in jsondiff's code that obviously returns a list out of itself.
1.txt
2.txt
The text was updated successfully, but these errors were encountered: