MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Map

Function Map

pkg/goproto/struct.go:60–80  ·  view source on GitHub ↗

Map returns the Struct proto as a map[string]interface{}.

(p *structpb.Struct, opts ...Option)

Source from the content-addressed store, hash-verified

58
59// Map returns the Struct proto as a map[string]interface{}.
60func Map(p *structpb.Struct, opts ...Option) (map[string]any, error) {
61 if p == nil || len(p.Fields) == 0 {
62 return nil, nil
63 }
64 state, err := createSerializationState(opts...)
65 if err != nil {
66 return nil, err
67 }
68 m := make(map[string]any, len(p.Fields))
69 for k, v := range p.Fields {
70 if v == nil {
71 continue
72 }
73 gv, err := Interface(v, state.Recurse())
74 if err != nil {
75 return nil, err
76 }
77 m[k] = gv
78 }
79 return m, nil
80}
81
82// Slice returns the ListValue proto as a []interface{}.
83func Slice(l *structpb.ListValue, opts ...Option) ([]any, error) {

Callers 15

TestLegacyDecodeUplinkFunction · 0.92
TestDecodeUplinkFunction · 0.92
TestDecodeDownlinkFunction · 0.92
encodeDownlinkMethod · 0.92
EncodeDownlinkMethod · 0.92
TestEncodeFunction · 0.92
TestDecodeFunction · 0.92
PublicAttributesMethod · 0.92
locationFromPayloadMethod · 0.92
gnssQueryMethod · 0.92
wifiQueryMethod · 0.92

Calls 3

createSerializationStateFunction · 0.85
RecurseMethod · 0.80
InterfaceFunction · 0.70

Tested by 8

TestLegacyDecodeUplinkFunction · 0.74
TestDecodeUplinkFunction · 0.74
TestDecodeDownlinkFunction · 0.74
TestEncodeFunction · 0.74
TestDecodeFunction · 0.74
TestStructProtoFunction · 0.74
TestRecursiveStructuresFunction · 0.74