Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · protojson

Docs

std/protojson

On this page

Index

Types

JsonErr

struct JsonErr {
  text: Str
}

Why a conversion failed; text is protojson’s message.

Source: std/protojson.xo:16

JsonErr.display

fn (e: JsonErr) display() -> Str

Source: std/protojson.xo:20

Opts

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).

Source: std/protojson.xo:25

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).

Source: std/protojson.xo:33

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.

Source: std/protojson.xo:39

Functions

registry

fn registry(files: List[protodesc.FileDesc]) -> Registry

A registry of the files (a file’s dependencies must be in the list).

Source: std/protojson.xo:47

registry_from_set

fn registry_from_set(set: Bytes) -> Registry ! protobuf.ProtoErr

A registry of a serialized FileDescriptorSet.

Source: std/protojson.xo:49

marshal

fn marshal(r: Registry, name: Str, wire: Bytes, o: Opts = Opts{}) -> Str ! JsonErr

The JSON text (compact, no whitespace) of the wire bytes of message name (pkg.Msg).

Source: std/protojson.xo:52

unmarshal

fn unmarshal(r: Registry, name: Str, json: Str, o: Opts = Opts{}) -> Bytes ! JsonErr

The wire bytes (fields in field number order, maps in key order: Go’s Deterministic marshaling) of the JSON text as message name.

Source: std/protojson.xo:55

↑ index