Documentation
¶
Overview ¶
Package jsons implements encoding and decoding of JSONS files and streams. The JSONS format is defined as compact JSON objects delimited by one newline. Each JSON object resides on its own line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileReader ¶
type FileReader struct {
// contains filtered or unexported fields
}
FileReader is a wrapper around a Reader to read JSONS data from a file.
func NewFileReader ¶
func NewFileReader(filename string) *FileReader
NewFileReader returns a pointer on a new FileReader which will read its data from the given file.
func (*FileReader) Next ¶
func (fr *FileReader) Next(v interface{}) error
Next unmarshals the next JSON object in the given value, which must be a pointer.
func (*FileReader) Open ¶
func (fr *FileReader) Open() error
Open opens the underlying file for reading. You must call this before any Close or Next call.
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
FileWriter is a wrapper around a Writer which writes JSONS data in a file.
func NewFileWriter ¶
func NewFileWriter(filename string) *FileWriter
NewFileWriter returns a pointer on a new FileWriter which will write in the given filename. The file is truncated if it already exists.
func (*FileWriter) Add ¶
func (fw *FileWriter) Add(v interface{}) error
Add encodes the given value as a JSON object and write it in the underlying file.
func (*FileWriter) AddAll ¶ added in v1.1.0
func (fw *FileWriter) AddAll(args ...interface{}) error
AddAll is equivalent to calling Add on each of its arguments
func (*FileWriter) Close ¶
func (fw *FileWriter) Close() error
Close closes the underlying file. You must call this when you're done adding values.
func (*FileWriter) Open ¶
func (fw *FileWriter) Open() error
Open opens the underlying file for writing. This must be called before any Add or Close call.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a JSONS reader
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is a JSONS writer
func NewWriter ¶
NewWriter returns a new Writer, which writes JSONS-encoded data in the given io.Writer implementation.