Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode a JSON value from a readable. Can decode JSON object and arrays into slices and plain Go values.
If the decoding cannot happen, an error is returned. Otherwise, the value is written straight into v.
func Encode ¶
func Encode(w WriteSeekerTruncater, v interface{}) error
Encode a JSON value to a writer. The encoding is tailored towards jump JSON file needs. Every write truncates the writable and seeks it to it's beginning, so you can safely decode and encode without manipulating the writable.
Technically, the writable needs to implement WriterSeekerTruncater, but you'll most likely use an os.File.
Types ¶
type WriteSeekerTruncater ¶
type WriteSeekerTruncater interface { io.WriteSeeker Truncater }
WriteSeekerTruncater is the interface needed by the Encode first argument. It's a narrower type than a file, and can be more easily mocked in testing.