Debian Codegraph @

cty/json/simple.go

raw symbols SCIP
1 package jsonscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/
2
3 import (
4 "github.com/zclconf/go-cty/ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/"
5 )
6
7 // SimpleJSONValue is a wrapper around cty.Value that adds implementations of
8 // json.Marshaler and json.Unmarshaler for simple-but-type-lossy automatic
9 // encoding and decoding of values.
10 //
11 // The couplet Marshal and Unmarshal both take extra type information to
12 // inform the encoding and decoding process so that all of the cty types
13 // can be represented even though JSON's type system is a subset.
14 //
15 // SimpleJSONValue instead takes the approach of discarding the value's type
16 // information and then deriving a new type from the stored structure when
17 // decoding. This results in the same data being returned but not necessarily
18 // with exactly the same type.
19 //
20 // For information on how types are inferred when decoding, see the
21 // documentation of the function ImpliedType.
22 type SimpleJSONValuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/SimpleJSONValue# struct {
23 ctyscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/SimpleJSONValue#Value.
24 }
25
26 // MarshalJSON is an implementation of json.Marshaler. See the documentation
27 // of SimpleJSONValue for more information.
28 func (v SimpleJSONValuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/SimpleJSONValue#) MarshalJSONscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/SimpleJSONValue#MarshalJSON().() ([]byte, error) {
29 return Marshalscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/Marshal().(v.Valuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/SimpleJSONValue#Value., v.Typescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty`/Value#Type().())
30 }
31
32 // UnmarshalJSON is an implementation of json.Unmarshaler. See the
33 // documentation of SimpleJSONValue for more information.
34 func (v *SimpleJSONValuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/SimpleJSONValue#) UnmarshalJSONscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/SimpleJSONValue#UnmarshalJSON().(buf []byte) error {
35 t, err := ImpliedTypescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/ImpliedType().(buf)
36 if err != nil {
37 return err
38 }
39 v.Valuescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/SimpleJSONValue#Value., err = Unmarshalscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/json`/Unmarshal().(buf, t)
40 return err
41 }