aiowamp.JSONSerializer

class aiowamp.JSONSerializer(*, decoder=None, encoder=None)[source]

Serializer for the JSON format.

Provides a custom json.JSONDecoder and json.JSONEncoder which handle the special WAMP string format for binary data.

Parameters:
  • decoder (Optional[JSONDecoder]) –
  • encoder (Optional[JSONEncoder]) –
  • decoder – Decoder to be used. Defaults to JSONDecoder which supports binary data in strings.
  • encoder – Encoder to be used. Defaults to JSONEncoder which supports binary data in strings.
__init__(*, decoder=None, encoder=None)[source]
Parameters:
  • decoder (Optional[JSONDecoder]) – Decoder to be used. Defaults to JSONDecoder which supports binary data in strings.
  • encoder (Optional[JSONEncoder]) – Encoder to be used. Defaults to JSONEncoder which supports binary data in strings.
Return type:

None

Methods

__init__(*[, decoder, encoder])
type decoder:Optional[JSONDecoder]
deserialize(data) Deserialise the bytes representation of a message.
serialize(msg) Serialise a message.

Attributes

decoder JSON decoder used to decode incoming messages.
encoder JSON encoder used to encode outgoing messages.
__init__(*, decoder=None, encoder=None)[source]
Parameters:
  • decoder (Optional[JSONDecoder]) – Decoder to be used. Defaults to JSONDecoder which supports binary data in strings.
  • encoder (Optional[JSONEncoder]) – Encoder to be used. Defaults to JSONEncoder which supports binary data in strings.
Return type:

None

decoder

JSON decoder used to decode incoming messages.

encoder

JSON encoder used to encode outgoing messages.

serialize(msg)[source]

Serialise a message.

Parameters:msg (MessageABC) – Message to serialise.
Return type:bytes
Returns:bytes representation of the message.
Raises:Exception – If the message couldn’t be serialised.
deserialize(data)[source]

Deserialise the bytes representation of a message.

Parameters:

data (bytes) – bytes representation of a message.

Return type:

MessageABC

Returns:

Deserialised message.

Raises: