Make JSON formatting a feature flag, enabled by default

This commit is contained in:
Dan Sosedoff
2017-09-13 23:27:54 -05:00
parent e44e66a8e8
commit d786d0018e
2 changed files with 30 additions and 21 deletions

View File

@@ -8,6 +8,8 @@ import (
"reflect"
"strconv"
"time"
"github.com/sosedoff/pgweb/pkg/command"
)
type Row []interface{}
@@ -108,7 +110,13 @@ func (res *Result) CSV() []byte {
}
func (res *Result) JSON() []byte {
data, _ := json.MarshalIndent(res.Format(), "", " ")
var data []byte
if command.Opts.EnablePrettyJson {
data, _ = json.MarshalIndent(res.Format(), "", " ")
} else {
data, _ = json.Marshal(res.Format())
}
return data
}