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, default=None)[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:
_UnionGenericAlias
[Decimal
,None
]- Returns:
Converted number.
- Return type:
Decimal