From 5cda6d3a1622167c5fed35bcd3a02a031ef7a86d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 26 Sep 2021 21:18:24 -0700 Subject: Tweaked number output. It uses an integer formatting when there is no fractional component to the number, and a fixed point format when there is. --- src/unstable/json.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/unstable/json.cpp b/src/unstable/json.cpp index 9745a7f..65bd195 100644 --- a/src/unstable/json.cpp +++ b/src/unstable/json.cpp @@ -429,7 +429,14 @@ void Bu::Json::write( Bu::Stream &sOutput ) const case Number: { char buf[64]; - sprintf( buf, "%f", uDat.dNumber ); + if( uDat.dNumber == floor( uDat.dNumber ) ) + { + sprintf( buf, "%ld", (int64_t)uDat.dNumber ); + } + else + { + sprintf( buf, "%f", uDat.dNumber ); + } sOutput.write( buf ); } break; -- cgit v1.2.3