I don't know if this is a bug in Play! or if there is another cause, but here is what is happening.
I have an object (MyObject) that has a member variable of type Float.
public class MyObject {
private Float data;
}
When using Json.toJson() (from play.libs.Json) to send the response containing a MyObject item, the values get scrambled.
As an example:
MyObject myObj = new MyObj();
myObj.setData(3.2f);
JSON string:
{
"data": 3.200000047683716
}
If I change the data type to Double, everything works fine.
I suspect it may be because of float precision vs double precision and how JSON.toJson() handles Float objects, however, in debug, myObj.data is 3.2.