faust.utils.json
¶
JSON utilities.
- class faust.utils.json.JSONEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None, use_decimal=True, namedtuple_as_object=True, tuple_as_array=True, bigint_as_string=False, item_sort_key=None, for_json=False, ignore_nan=False, int_as_string_bitcount=None, iterable_as_array=False)[source]¶
Faust customized
json.JSONEncoder
.Our version supports additional types like
UUID
, and importantly includes microsecond information in datetimes.
- faust.utils.json.dumps(obj: ~typing.Any, json_dumps: ~typing.Callable = <function dumps>, cls: ~typing.Type[~faust.utils.json.JSONEncoder] = <class 'faust.utils.json.JSONEncoder'>, **kwargs: ~typing.Any) str [source]¶
Serialize to json. See
json.dumps()
.- Return type:
- faust.utils.json.loads(s: str, json_loads: ~typing.Callable = <function loads>, **kwargs: ~typing.Any) Any [source]¶
Deserialize json string. See
json.loads()
.- Return type:
- faust.utils.json.str_to_decimal(s: str, maxlen: int = 1000) Optional[Decimal] [source]¶
Convert string to
Decimal
.- Parameters:
- Raises:
ValueError – if length exceeds maximum length, or if value is not a valid number (e.g. Inf, NaN or sNaN).
- Return type:
_GenericAlias
[Decimal
,None
]- Returns:
Converted number.
- Return type:
Decimal