go-hep.org/x/hep@v0.38.1/fwk/job/jsoncodec.go (about) 1 // Copyright ©2017 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package job 6 7 import ( 8 "encoding/json" 9 "io" 10 "os" 11 ) 12 13 // NewJSONEncoder returns a new encoder that writes to w 14 func NewJSONEncoder(w io.Writer) *json.Encoder { 15 if w == nil { 16 w = os.Stdout 17 } 18 return json.NewEncoder(w) 19 } 20 21 // NewJSONDecoder returns a new decoder that reads from r. 22 func NewJSONDecoder(r io.Reader) *json.Decoder { 23 return json.NewDecoder(r) 24 }