summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/chavacava/garif/io.go
blob: ce5719c96d1c7477450ae8f150a02c83eb07ddd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package garif

import (
	"encoding/json"
	"io"
)

// Write writes the JSON
func (l *LogFile) Write(w io.Writer) error {
	marshal, err := json.Marshal(l)
	if err != nil {
		return err
	}
	_, err = w.Write(marshal)
	return err
}

// PrettyWrite writes indented JSON
func (l *LogFile) PrettyWrite(w io.Writer) error {
	marshal, err := json.MarshalIndent(l, "", "  ")
	if err != nil {
		return err
	}
	_, err = w.Write(marshal)
	return err
}