Deserializes conflict to a JSON object.

        It returns list of:
            `json-patch <https://tools.ietf.org/html/rfc6902>`_ format.

        - REORDER, SET_FIELD become "op": "replace"
        - MANUAL_MERGE, ADD_BACK_TO_HEAD become "op": "add"
        - Path becomes `json-pointer <https://tools.ietf.org/html/rfc6901>`_
        - Original conflict type is added to "$type"

def to_json(self):
        """Deserializes conflict to a JSON object.

        It returns list of:
            `json-patch <https://tools.ietf.org/html/rfc6902>`_ format.

        - REORDER, SET_FIELD become "op": "replace"
        - MANUAL_MERGE, ADD_BACK_TO_HEAD become "op": "add"
        - Path becomes `json-pointer <https://tools.ietf.org/html/rfc6901>`_
        - Original conflict type is added to "$type"
        """
        # map ConflictType to json-patch operator
        path = self.path
        if self.conflict_type in ('REORDER', 'SET_FIELD'):
            op = 'replace'
        elif self.conflict_type in ('MANUAL_MERGE', 'ADD_BACK_TO_HEAD'):
            op = 'add'
            path += ('-',)
        elif self.conflict_type == 'REMOVE_FIELD':
            op = 'remove'
        else:
            raise ValueError(
                'Conflict Type %s can not be mapped to a json-patch operation'
                % conflict_type
            )

        # stringify path array
        json_pointer = '/' + '/'.join(str(el) for el in path)

        conflict_values = force_list(self.body)
        conflicts = []
        for value in conflict_values:
            if value is not None or self.conflict_type == 'REMOVE_FIELD':
                conflicts.append({
                    'path': json_pointer,
                    'op': op,
                    'value': value,
                    '$type': self.conflict_type
                })

        return json.dumps(conflicts)