go: cuelang.org/go/encoding/json Index | Files

package json

import "cuelang.org/go/encoding/json"

Package json converts JSON to and from CUE.

Index

Package Files

json.go

func Decode Uses

func Decode(r *cue.Runtime, path string, b []byte) (*cue.Instance, error)

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 Uses

func Extract(path string, b []byte) (ast.Expr, error)

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 Uses

func Valid(b []byte) bool

Valid reports whether data is a valid JSON encoding.

func Validate Uses

func Validate(b []byte, v cue.Value) error

Validate validates JSON and confirms it matches the constraints specified by v.

type Decoder Uses

type Decoder struct {
    // contains filtered or unexported fields
}

A Decoder converts JSON values to CUE.

func NewDecoder Uses

func NewDecoder(r *cue.Runtime, path string, src io.Reader) *Decoder

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 Uses

func (d *Decoder) Decode() (*cue.Instance, error)

Decode converts the current JSON value to a CUE instance. It returns io.EOF if the input has been exhausted.

func (*Decoder) Extract Uses

func (d *Decoder) Extract() (ast.Expr, error)

Extract converts the current JSON value to a CUE ast. It returns io.EOF if the input has been exhausted.

Package json imports 12 packages (graph) and is imported by 2 packages. Updated 2019-11-14. Refresh now. Tools for package owners.