Warning: Massive error in json_encode()

前端 未结 3 1634
栀梦
栀梦 2021-01-19 05:29
  

Recieved in browser: [ \"1968401665333658496\"

相关标签:
3条回答
  • 2021-01-19 05:55

    Quote your integer value and handle the conversion on the client.

    0 讨论(0)
  • 2021-01-19 05:57

    It's not just a JSON issue. If you put

    alert(1968401665333658496);
    

    in firebug console you get 1968401665333658600

    You're probably hitting the JS max value.

    There's a discussion on that here : What is JavaScript's highest integer value that a Number can go to without losing precision?

    0 讨论(0)
  • 2021-01-19 06:18

    Javascript has no concept of integers, according to the standard all numbers are IEEE doubles, which means they have 52 bits of mantissa. this leads to a practical maximum "integer" value of 2^53 before any loss of precision.

    I am not sure how you didn't have problems with numbers this large in JS alone - if you didn't your JS implementation is not standards compliant.

    0 讨论(0)
提交回复
热议问题