Skip to content

Commit

Permalink
Fix unmarshalling long numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonymq committed Dec 4, 2024
1 parent a75e3e7 commit ba61cbc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tui/bubbles/jqplayground/commands.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jqplayground

import (
"bytes"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ba61cbc

Please sign in to comment.