How to use the jsonpatch.MoveOperation 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
[a, b, c, d, e]
         0  1, 2, 3, 4

        case 1: move 1 to 3
        [a, c, d, b, e]
         0  1, 2, 3, 4

        """

        key = self.get_index_change(path, key)
        newkey = self.get_index_change(path, newkey)

        if key == newkey:
            return

        new_op = MoveOperation({
            'op': 'move',
            'from': _path_join(path, key),
            'path': _path_join(path, newkey),
        })
        self.insert(new_op)

        self.add_index_change(path, key+1, -1)
        self.add_index_change(path, newkey+1, +1)
github stefankoegl / python-json-patch / jsonpatch.py View on Github external
def __init__(self, patch):
        self.patch = patch

        self.operations = {
            'remove': RemoveOperation,
            'add': AddOperation,
            'replace': ReplaceOperation,
            'move': MoveOperation,
            'test': TestOperation,
            'copy': CopyOperation,
        }