Skip to content

parsers

re_dump_value(value)

Re-dumps value due to different string representation in orjson and json :param value: string to re-dump :type value: str :return: re-dumped value :rtype: List[str]

Source code in ormar/fields/parsers.py
54
55
56
57
58
59
60
61
62
63
64
65
66
def re_dump_value(value: str) -> Union[str, bytes]:
    """
    Re-dumps value due to different string representation in orjson and json
    :param value: string to re-dump
    :type value: str
    :return: re-dumped value
    :rtype: List[str]
    """
    try:
        result: Union[str, bytes] = json.dumps(json.loads(value))
    except json.JSONDecodeError:
        result = value
    return result