Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/jq/jq.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func jsonScalarToString(input interface{}) (string, error) {
if math.Trunc(tt) == tt {
return strconv.FormatFloat(tt, 'f', 0, 64), nil
} else {
return strconv.FormatFloat(tt, 'f', 2, 64), nil
return strconv.FormatFloat(tt, 'f', -1, 64), nil
}
case nil:
return "", nil
Expand Down
10 changes: 10 additions & 0 deletions pkg/jq/jq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ func TestEvaluateFormatted(t *testing.T) {
" \x1b[32m\"bar\"\x1b[m\n" +
"\x1b[1;38m}\x1b[m\n",
},
{
name: "non-integer numbers keep full precision",
args: args{
json: strings.NewReader(`{"pi": 3.14159, "small": 0.001, "big": 123456.789}`),
expr: `.pi, .small, .big`,
indent: "",
colorize: false,
},
wantW: "3.14159\n0.001\n123456.789\n",
},
{
name: "halt function",
args: args{
Expand Down