Dictionary

The base class of the WebIDL dictionaries. Methods take them as typed dataclasses in place of plain dicts.

class webrtc.models.dictionary.Dictionary

The base class of the dataclasses of WebIDL dictionaries.

Methods take these dataclasses in place of plain dicts. from_json() and to_json() convert them to and from the JSON form that is exchanged with the remote peer.

classmethod from_json(value)

Creates the dictionary from its JSON form, like one received from the remote peer.

Keys can be the camelCase names of the specification or the snake_case ones. Unknown keys are ignored, and nested dictionaries are converted too.

Parameters:

value (dict) – The JSON form.

Returns:

The dictionary.

Raises:

TypeError – If the value isn’t a mapping, or a required member is missing.

Return type:

Self

to_json()

Returns the JSON form of the dictionary, like one to send to the remote peer.

Keys are the camelCase names of the specification. Members that are None are left out, enums become their values, and nested dictionaries are converted too.

Returns:

dict – The JSON form.

Return type:

dict[str, object]