Decimal formatting issue in net.sf.json Object

AsithaL :

We are using compile net.sf.json-lib:json-lib:2.4:jdk15

String requestBody =     {"resconfirmsvid":28,"reservationno":"H0028W090718","component":"Hotel","partnerid":2,"total":169002.15,"internalnote":"","currencycode":"USD","history":[{"id":"0","payment_type":"Payment","payment_method":"Cash","date":"2019-10-30","refnumber":"012525TRTY","amount":160000,"currency":"USD","component":"Hotel","resconfirmsvid":28}]}

requestBody = URLDecoder.decode(requestBody, "UTF-8");
JSONObject request = JSONObject.fromObject(requestBody);

Then request object as follows,

request = {"resconfirmsvid":28,"reservationno":"H0028W090718","component":"Hotel","partnerid":2,"total":169002.16,"internalnote":"","currencycode":"USD","history":[{"id":"0","payment_type":"Payment","payment_method":"Cash","date":"2019-10-30","refnumber":"012525TRTY","amount":160000,"currency":"USD","component":"Hotel","resconfirmsvid":28}]}

After convert json string into json object using fromObject "total" value changed to 169002.16 from 169002.15

hazzy1986 :

I got a same issue, when i used net.sf.json-lib for coverting json string into Json object.once i used the below gradle version
compile 'net.sf.json-lib:json-lib:2.3:jdk15' issue was fixed sucessfully.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=328239&siteId=1