Skip to content

parsers

re_dump_value(value)

Rw-dumps choices due to different string representation in orjson and json

Parameters:

Name Type Description Default
value str

string to re-dump

required

Returns:

Type Description
List[str]

re-dumped choices

Source code in ormar\fields\parsers.py
48
49
50
51
52
53
54
55
56
57
58
59
60
def re_dump_value(value: str) -> Union[str, bytes]:
    """
    Rw-dumps choices due to different string representation in orjson and json
    :param value: string to re-dump
    :type value: str
    :return: re-dumped choices
    :rtype: List[str]
    """
    try:
        result: Union[str, bytes] = json.dumps(json.loads(value))
    except json.JSONDecodeError:
        result = value
    return result