pyjackson.decorators module

class pyjackson.decorators.cached_property(method)[source]

Bases: object

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 params

Parameters:
  • 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
pyjackson.decorators.real_types(*types)[source]

Register multiple real types for one serializer

pyjackson.decorators.rename_fields(**field_mapping)[source]

Change name of fields in payload. This behavior is inheritable and overridable for child classes

Parameters:field_mapping – str-str mapping of field name (from constructor) to field name in payload
pyjackson.decorators.camel_case(cls)[source]

Change snake_case field names to camelCase names