avian2 / jsonmerge

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

Is it support uniqueItems in arrays? #42

Closed SmartManoj closed 5 years ago

SmartManoj commented 5 years ago
base = {
        "foo": 1,
        "bar": ["2"]
     }

head = {
        "bar": ["2"],
        "baz": "Hello, world!"
    }
schema = {  
            "properties": {
                "bar": {
                    "uniqueItems": True,
                    "mergeStrategy": "append",
                }
            }
        }

from jsonmerge import Merger
from pprint import *
merger = Merger(schema)
result = merger.merge(base, head)

pprint(result, width=40)
{'bar': ['2'],
 'baz': 'Hello, world!',
 'foo': 1}