Skip to main content
func (d datasets.DatapointDecoder) Unmarshal(
    descriptor *datasets.DatapointDescriptor,
    data []byte,
) (map[string]any, error)
Decode a raw protobuf datapoint into a JSON-like map with configurable protobuf decoding options.

Parameters

descriptor
*datasets.DatapointDescriptor
required
The descriptor returned by NewDatapointDescriptor.
data
[]byte
required
The raw protobuf datapoint bytes returned by a datapoint query.

Decoder options

AllowPartial
bool
Allow messages that are missing required fields.
DiscardUnknown
bool
Ignore unknown fields in the raw protobuf message.
Resolver
Override the resolver used to look up message and extension types.
RecursionLimit
int
Limit how deeply nested messages may be decoded. A zero value uses the protobuf default.

Returns

A map of datapoint fields, or an error if the raw datapoint cannot be decoded.
decoder := datasets.DatapointDecoder{
    DiscardUnknown: true,
}

datapoint, err := decoder.Unmarshal(descriptor, data)
if err != nil {
    return err
}