module documentation

In-house ProtoJSON conversion for direct protobuf messages.

Exception JsonError Raised when a value does not satisfy ProtoJSON rules.
Function message_from_json Replace a direct message from a ProtoJSON document.
Function message_to_dict Convert a direct message to a ProtoJSON-compatible dictionary.
Function message_to_json Serialize a direct message to a ProtoJSON document.
Function message_to_value Convert a direct message to its ProtoJSON value.
Function parse_dict Replace a direct message from a ProtoJSON-compatible dictionary.
Function parse_value Replace a direct message from its ProtoJSON value.
Type Variable M Undocumented
Function _accepts_null Undocumented
Function _camel_to_snake Undocumented
Function _encode_map_key Undocumented
Function _encode_value Undocumented
Function _encode_well_known Undocumented
Function _extension_for_json_name Undocumented
Function _field Undocumented
Function _fraction Undocumented
Function _get Undocumented
Function _json_name Undocumented
Function _parse_duration Undocumented
Function _parse_extension Undocumented
Function _parse_integer Undocumented
Function _parse_map_key Undocumented
Function _parse_timestamp Undocumented
Function _parse_value Undocumented
Function _parse_well_known Undocumented
Function _reject_duplicate_keys Undocumented
Function _reject_json_constant Undocumented
Function _set Undocumented
Function _snake_to_camel Undocumented
Constant _ANY_VALUE_TYPES Undocumented
Constant _DURATION_MAX Undocumented
Constant _FLOAT32_MAX Undocumented
Constant _SKIP Undocumented
Constant _TIMESTAMP_MAX Undocumented
Constant _TIMESTAMP_MIN Undocumented
Constant _WRAPPERS Undocumented
def message_from_json(payload: str | bytes | bytearray, message: M, *, ignore_unknown_fields: bool = False) -> M: (source)

Replace a direct message from a ProtoJSON document.

def message_to_dict(message: Message, *, preserving_proto_field_name: bool = False, always_print_fields_with_no_presence: bool = False, use_integers_for_enums: bool = False) -> dict[str, Any]: (source)

Convert a direct message to a ProtoJSON-compatible dictionary.

def message_to_json(message: Message, *, preserving_proto_field_name: bool = False, always_print_fields_with_no_presence: bool = False, use_integers_for_enums: bool = False, indent: int | None = 2, sort_keys: bool = False) -> str: (source)

Serialize a direct message to a ProtoJSON document.

def message_to_value(message: Message, *, preserving_proto_field_name: bool = False, always_print_fields_with_no_presence: bool = False, use_integers_for_enums: bool = False) -> Any: (source)

Convert a direct message to its ProtoJSON value.

def parse_dict(data: Mapping[str, Any], message: M, *, ignore_unknown_fields: bool = False) -> M: (source)

Replace a direct message from a ProtoJSON-compatible dictionary.

def parse_value(data: Any, message: M, *, ignore_unknown_fields: bool = False) -> M: (source)

Replace a direct message from its ProtoJSON value.

Undocumented

Value
TypeVar('M',
        bound=Message)
def _accepts_null(codec: ValueCodec[Any]) -> bool: (source)

Undocumented

def _camel_to_snake(path: str) -> str: (source)

Undocumented

def _encode_map_key(codec: ValueCodec[Any], value: Any) -> str: (source)

Undocumented

def _encode_value(codec: ValueCodec[Any], value: Any, *, preserving_proto_field_name: bool, always_print_fields_with_no_presence: bool, use_integers_for_enums: bool) -> Any: (source)

Undocumented

def _encode_well_known(message: Message, *, preserving_proto_field_name: bool, always_print_fields_with_no_presence: bool, use_integers_for_enums: bool) -> tuple[bool, Any]: (source)

Undocumented

def _extension_for_json_name(message: Message, name: str) -> Extension[Any] | None: (source)

Undocumented

def _field(message: Message, name: str) -> Field: (source)

Undocumented

def _fraction(nanos: int) -> str: (source)

Undocumented

def _get(message: Message, name: str) -> Any: (source)

Undocumented

def _json_name(field: Field) -> str: (source)

Undocumented

def _parse_duration(value: Any, message: Message): (source)

Undocumented

def _parse_extension(message: Message, extension: Extension[Any], raw: Any, ignore_unknown_fields: bool): (source)

Undocumented

def _parse_integer(value: Any) -> int: (source)

Undocumented

def _parse_map_key(codec: ValueCodec[Any], key: Any) -> Any: (source)

Undocumented

def _parse_timestamp(value: Any, message: Message): (source)

Undocumented

def _parse_value(codec: ValueCodec[Any], value: Any, *, ignore_unknown: bool) -> Any: (source)

Undocumented

def _parse_well_known(value: Any, message: Message, *, ignore_unknown_fields: bool) -> bool: (source)

Undocumented

def _reject_duplicate_keys(pairs: list[tuple[str, Any]]) -> dict[str, Any]: (source)

Undocumented

def _reject_json_constant(value: str) -> Any: (source)

Undocumented

def _set(message: Message, name: str, value: Any): (source)

Undocumented

def _snake_to_camel(path: str) -> str: (source)

Undocumented

_ANY_VALUE_TYPES = (source)

Undocumented

Value
_WRAPPERS | set(['google.protobuf.Any',
                 'google.protobuf.Duration',
                 'google.protobuf.FieldMask',
                 'google.protobuf.ListValue',
                 'google.protobuf.Struct',
                 'google.protobuf.Timestamp',
                 'google.protobuf.Value'])
_DURATION_MAX: int = (source)

Undocumented

Value
315576000000
_FLOAT32_MAX: float = (source)

Undocumented

Value
3.4028234663852886e+38

Undocumented

Value
object()
_TIMESTAMP_MAX: int = (source)

Undocumented

Value
253402300799
_TIMESTAMP_MIN: int = (source)

Undocumented

Value
-62135596800
_WRAPPERS: set[str] = (source)

Undocumented

Value
set(['google.protobuf.BoolValue',
     'google.protobuf.BytesValue',
     'google.protobuf.DoubleValue',
     'google.protobuf.FloatValue',
     'google.protobuf.Int32Value',
     'google.protobuf.Int64Value',
     'google.protobuf.StringValue',
...