title: Javascript long integer
body: <p>I have seen one of the weirdest things in javascript.
  The server side (spring):</p>
  
  <pre><code>   @RequestMapping(value = "/foo", method = RequestMethod.GET)
     @ResponseBody
     public Long foo() {
        return 793548328091516928L;
     }
  </code></pre>
  
  <p>I return a single long value and:</p>
  
  <pre><code>$.get('/foo').done(function(data){
      console.log(data);
  });
  </code></pre>
  
  <p>It represents the long integer as "793548328091516900" replacing (rounding indeed) the last two digits with 0s. When i make that GET request from any browser's address bar, the number represented correctly; thus this is a js issue, in my opinion.</p>
  
  <p>Returning a string instead of long from server and handling it with:</p>
  
  <pre><code>var x = new Number(data).toFixed();
  </code></pre>
  
  <p>obviously a solution. But I am not so lucky that, I have to handle a complex POJO (converted to JSON) whose some fields (some are nested) are typed with <code>java.lang.Long</code> type. If i try to cast this POJO to another object does not having fields typed Long, it is obviously cumbersome. </p>
  
  <p>Is there any solution to that obstacle in a clearer way?</p>