MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / UnmarshalJSON

Method UnmarshalJSON

cli/internal/specs/v0/spec.go:24–54  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

22}
23
24func (s *Spec) UnmarshalJSON(data []byte) error {
25 var t struct {
26 Kind Kind `json:"kind"`
27 Spec any `json:"spec"`
28 }
29 dec := json.NewDecoder(bytes.NewReader(data))
30 dec.DisallowUnknownFields()
31 dec.UseNumber()
32 if err := dec.Decode(&t); err != nil {
33 return err
34 }
35 s.Kind = t.Kind
36 switch s.Kind {
37 case KindSource:
38 s.Spec = new(Source)
39 case KindDestination:
40 s.Spec = new(Destination)
41 case KindTransformer:
42 s.Spec = new(Transformer)
43 default:
44 return fmt.Errorf("unknown kind %s", s.Kind)
45 }
46 b, err := json.Marshal(t.Spec)
47 if err != nil {
48 return err
49 }
50 dec = json.NewDecoder(bytes.NewReader(b))
51 dec.UseNumber()
52 dec.DisallowUnknownFields()
53 return dec.Decode(s.Spec)
54}
55
56func (Spec) JSONSchemaExtend(sc *jsonschema.Schema) {
57 // delete & obtain the values

Callers 2

TestRecordFunction · 0.45
parseJSONSchemaFunction · 0.45

Calls 1

ErrorfMethod · 0.80

Tested by 1

TestRecordFunction · 0.36