While converting JSON String to JSON array, numbers are getting rounded

248 Views Asked by At

While I'm converting JSON String to JSON array the decimal part is getting rounded. On below example the value given is 33648.545 and the output is 33648.547. The library used is 'json-lib-2.4-jdk15.jar'. Can any one help to resolve the case.

import net.sf.json.JSONArray;
import net.sf.json.JSONSerializer;

public class TestCode{

public static void main(String[] args){
  String jsonStr2 = "[{\"amount\":33648.545}]";
  JSONArray jArrayStr = (JSONArray) JSONSerializer.toJSON(jsonStr2);
  System.out.println(jArrayStr);
}
}
0

There are 0 best solutions below