credmark.dto.encoder.PydanticJSONEncoder
- class PydanticJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
Bases:
JSONEncoder
A JSON encoder that will handle DTO types embedded in other data structures such as dicts or lists.
- Use it as the cls passed to json dump(s):
json.dump(result, cls=PydanticJSONEncoder)
Methods
default
encode
Encode the given object and yield each string representation as available.
Attributes
item_separator
key_separator
- iterencode(o, _one_shot=False)
Encode the given object and yield each string representation as available.
For example:
for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk)