// Package jx implements RFC 7159 json encoding and decoding.
package jx import ( ) // Valid reports whether data is valid json. func ( []byte) bool { := GetDecoder() defer PutDecoder() .ResetBytes() return .Validate() == nil } var ( encPool = &sync.Pool{ New: func() interface{} { return &Encoder{} }, } writerPool = &sync.Pool{ New: func() interface{} { return &Writer{} }, } decPool = &sync.Pool{ New: func() interface{} { return &Decoder{} }, } ) // GetDecoder gets *Decoder from pool. func () *Decoder { return decPool.Get().(*Decoder) } // PutDecoder puts *Decoder into pool. func ( *Decoder) { .Reset(nil) decPool.Put() } // GetEncoder returns *Encoder from pool. func () *Encoder { return encPool.Get().(*Encoder) } // PutEncoder puts *Encoder to pool func ( *Encoder) { .Reset() .SetIdent(0) encPool.Put() } // GetWriter returns *Writer from pool. func () *Writer { return writerPool.Get().(*Writer) } // PutWriter puts *Writer to pool func ( *Writer) { .Reset() writerPool.Put() }