Closed RayPlante closed 7 years ago
I would like to chase down the Travis failures for the different python versions, but nothing is showing in the output logs. Is this normal?
(I think there was an issue with Travis preventing me from seeing logs; it's okay now.)
Anyway, I've solved the python3 and python2.6 failures as you can see. OrderedDict, of course, is not available in python 2.6.
Hi. Thanks for your pull request. I'm a bit busy at the moment and it will take me a few days to look into it.
Thanks again for a very nice pull request and sorry for the late reply. I'm really happy to see such a well documented change.
Before merging this, I would prefer to rename a few things for consistency. Names in JSON Schema use camelCase, so I would rather use objClass
name for the option. Also, obj_cls_menu
would be better named objclass_menu
to use the same contraction as in other places.
I already did these changes in this branch: https://github.com/avian2/jsonmerge/tree/objclass
Another thing is that default
name for using the dict
class seems inconsistent. I think it would be better to simply use dict
in obj_cls_menu
.
I reworked a bit how the default class is handled. It's now possible the specify dict
and OrderedDict
directly in objClass
. Default value is stored under _default
key in objclass_menu
and is not part of the public interface.
This is the version that I plan to merge: https://github.com/avian2/jsonmerge/tree/objclass
This all looks great--thanks for the clean up! I'll give it a test drive.
I took the objclass branch for a quick once-around. Apart from the minor Merger constructor argument change, this appears to be a drop-in replacement for my submitted version; everything works fine. I'm developing some code around this at the moment, so if I run into any bugs or issues, I'll certainly pass them on. Thanks for the great code! It's a perfect match to what I was looking for.
Merged. Thanks for your contribution.
The main motivation for this PR is to provide a way to have
jsonmerge
to use theOrderedDict
class for JSON object data in the merged result. This is analogous to thejson
package's support for theobject_pairs_hook
parameter. And like thatjson
parameter, this PR tries to generalize the ability to customize the JSON object class.The changes in the interfaces occur in the
Merger
class and theObjectMerge
strategy class. The Merger class has built-in options for using eitherdict
orOrderedDict
, so the easiest way to use the latter throughout the merged result is to set the constructor'sobjclass
parameter to'OrderedDict'
.This PR also allows one to set the object class on a per JSON object type level. This is done via the
objclass
mergeOption to the objectMerge strategy. Setting this option can be set to either'OrderedDict'
or'default'
to haveObjectMerge
ordict
used as an object container for that type. Other classes can be made available to this option by providing a dictionary of class via theMerger
constructor'sobj_cls_menu
.For full details, see the new text added to the README.rst and inline documentation for the
Merger
andObjectMerge
class. This PR includes some added tests.