Take for example this short JSON taken as a String
from an API response using RestAssured
:
{
"id": "4d27afb18bfa4eb5917beee9aaddfa76",
"hedgeId": 205598,
"sellCurrency": "USD",
"buyCurrency": "EUR",
"buyAmount": 473935.00,
"sellAmount": 585538.30,
}
Whenever I do JSONObject foo = new JSONObject(thatStringAbove);
, this instance is created:
{
"hedgeId": 205598,
"buyAmount": 473935,
"sellAmount": 585538.3,
"id": "4d27afb18bfa4eb5917beee9aaddfa76",
"sellCurrency": "USD",
"buyCurrency": "EUR"
}
Notice the trailing zeros from amount nodes are stripped. This looks like a bug to me but does anyone know of a workaround / solution how to prevent this from happening?
Few notes:
Maven dependency:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20170516</version>
</dependency>
Appreciate the help!