Re: [json-lib-user] Rounding of JSON Number format
Brought to you by:
aalmiray
From: Jonathan G. <jso...@ki...> - 2017-06-23 18:03:46
|
The simplest way is to make sure json-lib knows that you're passing it a double by adding the "d" suffix to your number: JSONObject req = JSONObject.fromObject("{\"number\" : 500000.99d}"); json-lib parses "500000.99" as a Float (500001.0) and then converts it to a double (500001.0). Jonathan On Fri, Jun 23, 2017 at 8:32 AM, Silvano Maffeis <sil...@vi...> wrote: > Hi > > How can I avoid that this JSON number is rounded to 500001.0 ? > > JSONObject req = JSONObject.fromObject("{\"number\" : 500000.99}"); > > System.err.println("number=" + req.get("number")); > > => number=500001.0 > > Regards, > Silvano > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > json-lib-user mailing list > jso...@li... > https://lists.sourceforge.net/lists/listinfo/json-lib-user > |