diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-16 16:53:53 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-18 22:45:54 -0700 |
commit | 1a5b0561f53441d8a259a5096281699b5af16a6c (patch) | |
tree | aed7ab3089889582d7d817900d0796fb54acb0ab /reencode.go | |
parent | dfc67cecbd95344d296c31b537fa3ae8aec8c292 (diff) |
reencode: Add CompactFloats
Diffstat (limited to 'reencode.go')
-rw-r--r-- | reencode.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/reencode.go b/reencode.go index 1a9999b..1943b9c 100644 --- a/reencode.go +++ b/reencode.go @@ -54,6 +54,10 @@ type ReEncoderConfig struct { // this is different than the usual behavior. ForceTrailingNewlines bool + // CompactFloats causes the *ReEncoder to trim unnecessary '0' + // digits from floating-point number values. + CompactFloats bool + // A JSON document is specified to be a sequence of Unicode // codepoints; InvalidUTF8 controls how the *ReEncoder behaves // when it encounters invalid UTF-8 bytes in a JSON string @@ -109,8 +113,10 @@ func NewReEncoder(out io.Writer, cfg ReEncoderConfig) *ReEncoder { } // Numbers - module = &reEncodeCompactNum{ - out: module, + if cfg.CompactFloats { + module = &reEncodeCompactNum{ + out: module, + } } // Strings |