From ba61cbc76868cacaf6dd62e9f399b584447082a4 Mon Sep 17 00:00:00 2001 From: AnthonyMQ Date: Wed, 4 Dec 2024 10:40:52 +0100 Subject: [PATCH] Fix unmarshalling long numbers --- tui/bubbles/jqplayground/commands.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tui/bubbles/jqplayground/commands.go b/tui/bubbles/jqplayground/commands.go index a4eb4d9..92bc3cf 100644 --- a/tui/bubbles/jqplayground/commands.go +++ b/tui/bubbles/jqplayground/commands.go @@ -1,6 +1,7 @@ package jqplayground import ( + "bytes" "context" "encoding/json" "fmt" @@ -46,15 +47,19 @@ func processQueryResults(ctx context.Context, results *strings.Builder, query *g if r, err := gojq.Marshal(v); err == nil { results.WriteString(fmt.Sprintf("%s\n", string(r))) } + } return nil } func processJSONWithQuery(ctx context.Context, results *strings.Builder, query *gojq.Query, data []byte) error { + d := json.NewDecoder(bytes.NewReader(data)) + d.UseNumber() var obj any - if err := json.Unmarshal(data, &obj); err != nil { + if err := d.Decode(&obj); err != nil { return err } + err := processQueryResults(ctx, results, query, obj) if err != nil { return err