Using a rest service, we are transfering values using JSON.
At some point, we need to decide, wheter the incoming value was a long or a double. While
Double d = 17.0;
System.out.println("toString(): " + d.toString());
will result in
toString(): 17.0
the zero and the point gets removed, when wrapping the value inside a JSONObject:
JSONObject jo = new JSONObject();
jo.put("myDouble", d);
System.out.println(jo.toString());
Output:
{"myDouble":17}
The rest-Service has basically an EAV-Store, so it should not determine the type by the ValueNAME given. I testet 2 JSON-Implementations, both have the same behaviour.
can i somehow achieve, that the decimal value is appended in the JSONObject, without having to create my own implementation for it?