MCPcopy
hub / github.com/wavetermdev/waveterm / FromJsonMap

Function FromJsonMap

pkg/waveobj/waveobj.go:276–299  ·  view source on GitHub ↗
(m map[string]any)

Source from the content-addressed store, hash-verified

274}
275
276func FromJsonMap(m map[string]any) (WaveObj, error) {
277 otype, ok := m[OTypeKeyName].(string)
278 if !ok {
279 return nil, fmt.Errorf("missing otype")
280 }
281 desc := getWaveObjDesc(otype)
282 if desc == nil {
283 return nil, fmt.Errorf("unknown otype: %s", otype)
284 }
285 wobj := reflect.Zero(desc.RType).Interface().(WaveObj)
286 dconfig := &mapstructure.DecoderConfig{
287 Result: &wobj,
288 TagName: "json",
289 }
290 decoder, err := mapstructure.NewDecoder(dconfig)
291 if err != nil {
292 return nil, err
293 }
294 err = decoder.Decode(m)
295 if err != nil {
296 return nil, err
297 }
298 return wobj, nil
299}
300
301func ORefFromMap(m map[string]any) (*ORef, error) {
302 oref := ORef{}

Callers 3

convertSpecialFunction · 0.92
FromJsonFunction · 0.85
UnmarshalJSONMethod · 0.85

Calls 1

getWaveObjDescFunction · 0.85

Tested by

no test coverage detected