MCPcopy Create free account
hub / github.com/tendermint/tendermint / decodeReflectStruct

Function decodeReflectStruct

libs/json/decoder.go:176–202  ·  view source on GitHub ↗
(bz []byte, rv reflect.Value)

Source from the content-addressed store, hash-verified

174}
175
176func decodeReflectStruct(bz []byte, rv reflect.Value) error {
177 if !rv.CanAddr() {
178 return errors.New("struct value is not addressable")
179 }
180 sInfo := makeStructInfo(rv.Type())
181
182 // Decode raw JSON values into a string-keyed map.
183 rawMap := make(map[string]json.RawMessage)
184 if err := json.Unmarshal(bz, &rawMap); err != nil {
185 return err
186 }
187 for i, fInfo := range sInfo.fields {
188 if !fInfo.hidden {
189 frv := rv.Field(i)
190 bz := rawMap[fInfo.jsonName]
191 if len(bz) > 0 {
192 if err := decodeReflect(bz, frv); err != nil {
193 return err
194 }
195 } else if !fInfo.omitEmpty {
196 frv.Set(reflect.Zero(frv.Type()))
197 }
198 }
199 }
200
201 return nil
202}
203
204func decodeReflectInterface(bz []byte, rv reflect.Value) error {
205 if !rv.CanAddr() {

Callers 1

decodeReflectFunction · 0.85

Calls 5

makeStructInfoFunction · 0.85
decodeReflectFunction · 0.85
TypeMethod · 0.65
SetMethod · 0.65
UnmarshalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…