I just coded to put an array of double values in the JsonObject
. But, all my double values are converted to int values, when i print it. can someone help me understand what is happening behind? Please let me know the best way to put primitive arrays in JsonObject
public class JsonPrimitiveArrays {
public static void main(String[] args) {
JSONObject jsonObject = new JSONObject();
double[] d = new double[]{1.0,2.0,3.0};
jsonObject.put("doubles",d);
System.out.println(jsonObject);
}
}
Output:
{"doubles":[1,2,3]}