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

Method UnmarshalJSON

pkg/waveobj/wtype.go:89–129  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

87}
88
89func (update *WaveObjUpdate) UnmarshalJSON(data []byte) error {
90 var objMap map[string]any
91 err := json.Unmarshal(data, &objMap)
92 if err != nil {
93 return err
94 }
95 var ok1, ok2, ok3 bool
96 if _, found := objMap["updatetype"]; !found {
97 return fmt.Errorf("missing updatetype (in WaveObjUpdate)")
98 }
99 update.UpdateType, ok1 = objMap["updatetype"].(string)
100 if !ok1 {
101 return fmt.Errorf("in WaveObjUpdate bad updatetype type %T", objMap["updatetype"])
102 }
103 if _, found := objMap["otype"]; !found {
104 return fmt.Errorf("missing otype (in WaveObjUpdate)")
105 }
106 update.OType, ok2 = objMap["otype"].(string)
107 if !ok2 {
108 return fmt.Errorf("in WaveObjUpdate bad otype type %T", objMap["otype"])
109 }
110 if _, found := objMap["oid"]; !found {
111 return fmt.Errorf("missing oid (in WaveObjUpdate)")
112 }
113 update.OID, ok3 = objMap["oid"].(string)
114 if !ok3 {
115 return fmt.Errorf("in WaveObjUpdate bad oid type %T", objMap["oid"])
116 }
117 if _, found := objMap["obj"]; found {
118 objMap, ok := objMap["obj"].(map[string]any)
119 if !ok {
120 return fmt.Errorf("in WaveObjUpdate bad obj type %T", objMap["obj"])
121 }
122 waveObj, err := FromJsonMap(objMap)
123 if err != nil {
124 return fmt.Errorf("in WaveObjUpdate error decoding obj: %w", err)
125 }
126 update.Obj = waveObj
127 }
128 return nil
129}
130
131type Client struct {
132 OID string `json:"oid"`

Callers

nothing calls this directly

Calls 1

FromJsonMapFunction · 0.85

Tested by

no test coverage detected