Using Play Framework.
Controller
@BodyParser.Of(BodyParser.Json.class)
public static Result getResponseJson(Long id){
List<DataField> entities = new Model.Finder<>(Long.class, DataField.class)
.where("response_id = " + id).findList();
Response response = new Response(entities, id);
return ok(toJson(response));
}
The Response
entity is:
public class Response {
private Long uuid;
private Map<TableField, String> map = new HashMap<>();
...constructors, getters and setters...
}
I check the response with POSTMAN. On the tab "Raw" I got:
{"uuid":3942015886343226874,"map":{"Work":"Contract","locale":"Mogilev"}}
On the tab "Pretty":
{
"uuid": 3942015886343227000,
"map": {
"Work": "Contract",
"locale": "Mogilev"
}
}
Why the uuid is got rounded?
It is not related to Playframework it is a browser issue. Open the developer console in your browser and try this -
var c = 3942015886343226874;
console.log(c);
This will print - 3942015886343227000
because of number limit in JavaScript.
Its better to use String in case of UUID.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With