jsonfile

package module
v0.0.0-...-0f56d9e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2016 License: MIT Imports: 3 Imported by: 1

README

Go JSON File Handling

This package provides simple wrapping around saving and reading JSON files (streams) in GO. It exists because way too many sample/demo code are doing it the wrong way. Wrong in the sense of efficiency -- when reading JSON from file for example, the right is to read from stream, instead of reading the whole file via ioutil.ReadAll into a big buffer first then decode the buffer next.

Every single hit I searched, for "JSON files reading writing", is doing reading like this. They are actually not wrong, but just not ideal, especially when it comes to big JSON files.

Hence, this simple JSON files reading writing wrapping package.

Examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadJSON

func ReadJSON(r io.Reader, js interface{}) error

ReadJSON reads JSON from stream.

func ReadJSONFromFile

func ReadJSONFromFile(filename string, js interface{}) error

ReadJSONFromFile reads JSON from the file with given name.

func WriteJSON

func WriteJSON(w io.Writer, js interface{}) error

WriteJSON writes JSON to the stream.

func WriteJSONToFile

func WriteJSONToFile(filename string, js interface{}) error

WriteJSONFromFile writes JSON to the file with given name.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL