Skip to content

Commit

Permalink
JSON: don't minify numbers, fixes #400
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Apr 26, 2021
1 parent 8d45d96 commit db24cc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ module github.com/tdewolff/minify/v2

go 1.13

replace github.com/tdewolff/parse/v2 => ../parse

require (
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 // indirect
github.com/dustin/go-humanize v1.0.0
github.com/fsnotify/fsnotify v1.4.9
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2
github.com/spf13/pflag v1.0.5
github.com/tdewolff/parse/v2 v2.5.15
github.com/tdewolff/parse/v2 v2.5.16
github.com/tdewolff/test v1.0.6
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c // indirect
)
3 changes: 2 additions & 1 deletion json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func (o *Minifier) Minify(_ *minify.M, w io.Writer, r io.Reader, _ map[string]st
skipComma = gt == json.StartObjectGrammar || gt == json.StartArrayGrammar

if 0 < len(text) && ('0' <= text[0] && text[0] <= '9' || text[0] == '-') {
text = minify.Number(text, o.Precision)
// TODO: don't convert 1000 to 1e3 as it cannot be interpreted as an int by deserializers
//text = minify.Number(text, o.Precision)
if text[0] == '.' {
w.Write(zeroBytes)
} else if 1 < len(text) && text[0] == '-' && text[1] == '.' {
Expand Down

0 comments on commit db24cc6

Please sign in to comment.