avian2 / jsonmerge

Merge a series of JSON documents.
MIT License
214 stars 25 forks source link

Error when I use bracket in name #33

Closed borisalmonacid closed 6 years ago

borisalmonacid commented 6 years ago

------Error----- Traceback (most recent call last): File "mergejson.py", line 32, in mergejson('CFP01_C2_TIME_10_otros.json', 'CFP01_C2_TIME_10.json', 'salida.json') File "mergejson.py", line 23, in mergejson result = merger.merge(data1, data2) File "/usr/local/lib/python3.6/site-packages/jsonmerge/init.py", line 286, in merge return walk.descend(schema, base, head, meta).val File "/usr/local/lib/python3.6/site-packages/jsonmerge/init.py", line 78, in descend rv = self.work(strategy, schema, args, opts) File "/usr/local/lib/python3.6/site-packages/jsonmerge/init.py", line 123, in work rv = strategy.merge(self, base, head, schema, meta, objclass_menu=self.merger.objclass_menu, kwargs) File "/usr/local/lib/python3.6/site-packages/jsonmerge/strategies.py", line 270, in merge base[k] = walk.descend(subschema, base.get(k), v, meta) File "/usr/local/lib/python3.6/site-packages/jsonmerge/init.py", line 78, in descend rv = self.work(strategy, schema, args, opts) File "/usr/local/lib/python3.6/site-packages/jsonmerge/init.py", line 123, in work rv = strategy.merge(self, base, head, schema, meta, objclass_menu=self.merger.objclass_menu, kwargs) File "/usr/local/lib/python3.6/site-packages/jsonmerge/strategies.py", line 114, in merge raise HeadInstanceError("Head for an 'append' merge strategy is not an array", head) jsonmerge.exceptions.HeadInstanceError: Head for an 'append' merge strategy is not an array: #/[1]CFP01

------Data----- {"[1]CFP01":{"BAT":[{"times":[4],"values":[0.0]},{"times":[3],"values":[0.0]},{"times":[3],"values":[0.0]},{"times":[4],"values":[0.0]},{"times":[4],"values":[0.0]},{"times":[4],"values":[0.0]},{"times":[3],"values":[0.0]},{"times":[4,7],"values":[2.0,0.0]},{"times":[5],"values":[0.0]},{"times":[7],"values":.......

------ Solution (manual) Change in the file {"[1]CFP01":{"BAT ... to ... {"CFP01":{"BAT ...

avian2 commented 6 years ago

Hi. Your report doesn't have enough information for me to reproduce the issue.

File "mergejson.py", line 23, in mergejson
result = merger.merge(data1, data2)

Please include values for data1, data2 and how you instantiate the merger object (including the schema if any). I would appreciate if you could narrow down your data to the minimal set that causes the issue. Thanks.