elliotchance/gedcom

View on GitHub
q/json_formatter.go

Summary

Maintainability
A
0 mins
Test Coverage
package q

import (
    "encoding/json"
    "io"
)

type JSONFormatter struct {
    Writer io.Writer
}

func (f *JSONFormatter) Write(result interface{}) error {
    data, err := json.Marshal(result)
    if err != nil {
        return err
    }

    _, err = f.Writer.Write(append(data, '\n'))

    return err
}