Javascript 如何避免在客户端舍入长值?

Javascript 如何避免在客户端舍入长值?,javascript,java,json,long-integer,postman,Javascript,Java,Json,Long Integer,Postman,使用Play框架 控制器 @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

使用Play框架

控制器

@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));
}
我和邮递员核对了回复。在“原始”选项卡上,我得到:

在“漂亮”选项卡上:


为什么uuid被舍入?

它与Playframework无关,这是一个浏览器问题。在浏览器中打开开发人员控制台并尝试以下操作-

var c = 3942015886343226874;
console.log(c);
这将打印-394201588634327000

因为JavaScript中的数字限制


最好在UUID的情况下使用字符串。

js中的最大数字是+/-9007199254740992。JS只允许16位有效数字。我看到的唯一解决方案是在java中将uuid用作字符串,因此它将像字符串一样显示和操作,因此值不会更改。但无论如何,在其他函数中,JS可以将其定位为一个数字,因此将对其进行四舍五入。。。
{"uuid":3942015886343226874,"map":{"Work":"Contract","locale":"Mogilev"}}
{
  "uuid": 3942015886343227000,
  "map": {
    "Work": "Contract",
    "locale": "Mogilev"
  }
}
var c = 3942015886343226874;
console.log(c);