pyjackson.decorators module¶
-
pyjackson.decorators.
make_string
(*fields, include_name=True)[source]¶ Decorator to create a __str__ method for class based on __init__ arguments
Usage: directly
@make_string()
on class declaration to include all fields or@make_string(*fields, include_name)()
to alter paramsParameters: - fields – list of strings with field names
- include_name – whether to include class name
-
pyjackson.decorators.
as_list
(cls: Type[CT_co])[source]¶ Mark class to serialize it to list instead of dict
Parameters: cls – class to mark
-
pyjackson.decorators.
type_field
(field_name, position: pyjackson.core.Position = <Position.INSIDE: 0>, allow_reregistration=False)[source]¶ Class decorator for polymorphic hierarchies to define class field name, where subclass’s type alias will be stored Use it on hierarchy root class, add class field with defined name to any subclasses The same field name will be used during deserialization
Parameters: - field_name – class field name to put alias for type
- position – where to put type alias
- allow_reregistration – whether to allow reregistration of same alias or throw error