net.sf.jsonオブジェクトの小数点書式設定の問題

AsithaL:

私たちは、コンパイルを使用しています 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);

次のようにオブジェクトを要求、

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}]}

fromObjectを使用してJSONオブジェクトに変換するJSON文字列の後に「合計」の値に変更169002.16から169002.15

hazzy1986:

私は以下のGradleバージョンの使用object.once JSONにJSON文字列をcovertingためnet.sf.json-libが使用したのと同じ問題が、得た
compile 'net.sf.json-lib:json-lib:2.3:jdk15'問題が修正されましたsucessfullyを。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=335773&siteId=1