compact json and add \n delimiter for d4 piping

master
Jean-Louis Huynen 2019-03-01 15:13:40 +01:00
parent c779f589fe
commit 8fdae4a7d1
No known key found for this signature in database
GPG Key ID: 4CDEBABACE9A5DC9
1 changed files with 10 additions and 4 deletions

View File

@ -463,11 +463,17 @@ func output(t d4tls.TLSSession) {
} else {
panic(fmt.Sprintf("./%s does not exist", *outJSON))
}
// If not folder specidied, we output to stdout
// If not folder specified, we output to stdout
} else {
r := bytes.NewReader(jsonRecord)
_, err := io.Copy(os.Stdout, r)
if err != nil {
var buf bytes.Buffer
if err := json.Compact(&buf, jsonRecord); err != nil {
fmt.Println("Failed to compact json output")
}
if _, err := buf.Write([]byte{0x0A}); err != nil {
fmt.Println("Could not append delimiter")
}
if _, err := io.Copy(os.Stdout, &buf); err != nil {
panic("Could not write to stdout.")
}
}