package json
import "cuelang.org/go/encoding/json"
Package json converts JSON to and from CUE.
Index ¶
- func Decode(r *cue.Runtime, path string, b []byte) (*cue.Instance, error)
- func Extract(path string, b []byte) (ast.Expr, error)
- func Valid(b []byte) bool
- func Validate(b []byte, v cue.Value) error
- type Decoder
Functions ¶
func Decode ¶
Decode converts a JSON file to a CUE value.
If src != nil, Extract parses the source from src and the path is for position information. The type of the argument for the src parameter must be string, []byte, or io.Reader. If src == nil, ParseFile parses the file specified by filename.
func Extract ¶
Extract parses the JSON to a CUE expression.
If src != nil, Extract parses the source from src and the path is for position information. The type of the argument for the src parameter must be string, []byte, or io.Reader. If src == nil, ParseFile parses the file specified by filename.
func Valid ¶
Valid reports whether data is a valid JSON encoding.
func Validate ¶
Validate validates JSON and confirms it matches the constraints specified by v.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder converts JSON values to CUE.
func NewDecoder ¶
NewDecoder configures a JSON decoder. The path is used to associate position information with each node. The runtime may be nil if the decoder is only used to extract to CUE ast objects.
func (*Decoder) Decode ¶
Decode converts the current JSON value to a CUE instance. It returns io.EOF if the input has been exhausted.
func (*Decoder) Extract ¶
Extract converts the current JSON value to a CUE ast. It returns io.EOF if the input has been exhausted.
Source Files ¶
json.go
- Version
- v0.0.12
- Published
- Oct 19, 2019
- Platform
- windows/amd64
- Imports
- 12 packages
- Last checked
- 1 minute ago –
Tools for package owners.