diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2025-07-13 18:10:26 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2025-07-13 18:10:26 -0400 |
| commit | 86b712bfce3b0f57be197d6839138aea03034f1f (patch) | |
| tree | 2542164066ecb27be5c9e91fd98970887374a9e1 /pkg/query | |
| parent | d67596acd921f75caaa4e604bc1ccf163bd0729e (diff) | |
Correct multi-doc json output
Diffstat (limited to 'pkg/query')
| -rw-r--r-- | pkg/query/outputs.go | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/pkg/query/outputs.go b/pkg/query/outputs.go index a37cded..92331ef 100644 --- a/pkg/query/outputs.go +++ b/pkg/query/outputs.go @@ -139,21 +139,11 @@ func (o JsonOutput) Output(docs []*index.Document) (string, error) { } func (o JsonOutput) OutputTo(w io.Writer, docs []*index.Document) (int, error) { - n := 0 - for _, doc := range docs { - b, err := json.Marshal(doc) - if err != nil { - return n, err - } - - nn, err := w.Write(b) - if err != nil { - return n, err - } - n += nn + b, err := json.Marshal(docs) + if err != nil { + return 0, err } - - return n, nil + return w.Write(b) } func ParseOutputFormat(formatStr string) ([]OutputToken, []string, error) { |
