github.com/zerosnake0/jzon@v0.0.9-0.20230801092939-1b135cb83f7f/standard_compatible.go (about)

     1  package jzon
     2  
     3  import (
     4  	"io"
     5  )
     6  
     7  // Unmarshal parses the JSON-encoded data and stores the result
     8  // in the value pointed to
     9  func Unmarshal(data []byte, o interface{}) error {
    10  	return DefaultDecoderConfig.Unmarshal(data, o)
    11  }
    12  
    13  // Marshal returns the JSON encoding of object
    14  func Marshal(o interface{}) ([]byte, error) {
    15  	return DefaultEncoderConfig.Marshal(o)
    16  }
    17  
    18  // Valid reports whether data is a valid JSON encoding.
    19  func Valid(data []byte) bool {
    20  	it := NewIterator()
    21  	b := it.Valid(data)
    22  	it.Release()
    23  	return b
    24  }
    25  
    26  // NewDecoder returns a new decoder that reads from r.
    27  func NewDecoder(r io.Reader) *Decoder {
    28  	return DefaultDecoderConfig.NewDecoder(r)
    29  }
    30  
    31  // NewEncoder returns a new encoder that writes to w.
    32  func NewEncoder(w io.Writer) *Encoder {
    33  	return DefaultEncoderConfig.NewEncoder(w)
    34  }