std/protojson
On this page
Index
- type
JsonErr- method
JsonErr.display
- method
- type
Opts - type
Registry - type
MsgInfo - fn
registry - fn
registry_from_set - fn
marshal - fn
unmarshal
Types
JsonErr
struct JsonErr {
text: Str
}Why a conversion failed; text is protojson’s message.
JsonErr.display
fn (e: JsonErr) display() -> StrOpts
struct Opts {
proto_names: Bool = false
emit_defaults: Bool = false
enum_numbers: Bool = false
discard_unknown: Bool = false
}Go’s MarshalOptions and UnmarshalOptions: proto_names writes the proto field names (UseProtoNames),
emit_defaults writes default valued fields (EmitDefaultValues), enum_numbers writes enums as numbers
(UseEnumNumbers); discard_unknown skips unknown fields and enum names when reading (DiscardUnknown).
Registry
struct Registry {
msgs: Map[Str, MsgInfo]
enums: Map[Str, protodesc.EnumDesc]
}The messages and enums of a set of files, by full name (no leading dot).
MsgInfo
struct MsgInfo {
d: protodesc.MessageDesc
full: Str
proto3: Bool
is_map: Bool
}A message of a registry: its descriptor, full name, syntax and whether it is a map entry. Internal.
Functions
registry
fn registry(files: List[protodesc.FileDesc]) -> RegistryA registry of the files (a file’s dependencies must be in the list).
registry_from_set
fn registry_from_set(set: Bytes) -> Registry ! protobuf.ProtoErrA registry of a serialized FileDescriptorSet.
marshal
fn marshal(r: Registry, name: Str, wire: Bytes, o: Opts = Opts{}) -> Str ! JsonErrThe JSON text (compact, no whitespace) of the wire bytes of message name (pkg.Msg).
unmarshal
fn unmarshal(r: Registry, name: Str, json: Str, o: Opts = Opts{}) -> Bytes ! JsonErrThe wire bytes (fields in field number order, maps in key order: Go’s Deterministic marshaling) of the JSON
text as message name.