Documentation ¶
Index ¶
- func LoadDataFromCompressedJSON(dataReader io.Reader, v interface{}) error
- func LoadDataFromCompressedJSONFile(path string, v interface{}) error
- func LoadDataFromJSON(dataReader io.Reader, v interface{}) error
- func LoadDataFromJSONFile(path string, v interface{}) error
- func StoreDataToCompressedJSON(v interface{}, compressionLevel int) ([]byte, error)
- func StoreDataToCompressedJSONFile(path string, v interface{}, overwrite bool, compressionLevel int) error
- func StoreDataToJSON(v interface{}) ([]byte, error)
- func StoreDataToJSONFile(path string, v interface{}, overwrite bool) error
- type JSONError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadDataFromCompressedJSON ¶
LoadDataFromCompressedJSON converts the reader into a gzip.Reader and passes it to LoadDataFromJSON. Only closes the gzipReader, not the dataReader. Only returns errors of type jsonutil.JSONError.
func LoadDataFromCompressedJSONFile ¶
LoadDataFromCompressedJSONFile loads the content of a file specified by path and passes the file to LoadDataFromCompressedJSON. Makes path absolute. Closes all Readers. Only returns errors of type jsonutil.JSONError.
func LoadDataFromJSON ¶
LoadDataFromJSON uses ioutil.ReadAll to read the byte slice from dataReader and passes the slice to json.Unmarshal. It does not close the dataReader. Only returns errors of type jsonutil.JSONError.
func LoadDataFromJSONFile ¶
LoadDataFromJSONFile loads the content of a file specified by path. Makes path absolute Content is loaded into v. Returns a JSONError on failure.
func StoreDataToCompressedJSON ¶
StoreDataToCompressedJSON passes v to StoreDataToJSON. The JSON is then compressed into a buffer and buf.Bytes() is returned. Only returns errors of type jsonutil.JSONError.
func StoreDataToCompressedJSONFile ¶
func StoreDataToCompressedJSONFile(path string, v interface{}, overwrite bool, compressionLevel int) error
StoreDataToCompressedJSONFile converts the content of v into JSON if possible, compresses the byte slice using compressionLevel (gzip.constants) and stores the content into a file at path. Makes path absolute. If path already exists and the overwrite flag is not set, an error is returned.
func StoreDataToJSON ¶
StoreDataToJSON is the same as json.Marshal but only returns errors of type jsonutil.JSONError.
func StoreDataToJSONFile ¶
StoreDataToJSONFile converts the content of v into JSON if possible and stores the content into a file at path. Makes path absolute. If path already exists and the overwrite flag is not set, an error is returned.