How to use the jsonpatch.DiffBuilder function in jsonpatch

To help you get started, we’ve selected a few jsonpatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stefankoegl / python-json-patch / jsonpatch.py View on Github external
:type src: dict

        :param dst: Data source document object.
        :type dst: dict

        :return: :class:`JsonPatch` instance.

        >>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
        >>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]}
        >>> patch = JsonPatch.from_diff(src, dst)
        >>> new = patch.apply(src)
        >>> new == dst
        True
        """

        builder = DiffBuilder(src, dst)
        ops = list(builder.execute())
        return cls(ops)