javascript - How to avoid rounding of a long value on client side? -


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 , setters... } 

i check response postman. on tab "raw" got:

{"uuid":3942015886343226874,"map":{"work":"contract","locale":"mogilev"}} 

on tab "pretty":

{   "uuid": 3942015886343227000,   "map": {     "work": "contract",     "locale": "mogilev"   } } 

why uuid got rounded?

it not related playframework browser issue. open developer console in browser , try -

var c = 3942015886343226874; console.log(c); 

this print - 3942015886343227000

because of number limit in javascript.

its better use string in case of uuid.


Comments