Exemple #1
0
// WriteJSON write data from object to json file
func WriteJSON(fs filesystem.Filespace, path string, object interface{}) error {
	json, err := varutil.ObjectToJSON(object)
	if err != nil {
		return err
	}
	dir := filepath.Dir(path)
	if !fs.IsDir(dir) {
		if err := fs.MkdirAll(dir, 0777); err != nil {
			return err
		}
	}
	return fs.WriteFile(path, []byte(json), 0777)
}