2

I was looking at Openload.co API and I've seen that in the json response some numeric values are represented as integers while others as string, for example in this response:

{
    "status": 200,
    "msg": "OK",
    "result": {
        "extid": "extuserid",
        "email": "jeff@openload.io",
        "signup_at": "2015-01-09 23:59:54",
        "storage_left": -1,
        "storage_used": "32922117680",
        "traffic": {
          "left": -1,
          "used_24h": 0
        },
        "balance": 0
    }
}

storage_used is a strings and balance is integer. Since they are both numeric values and can't be strings in any case, is there some particular reason to set storage_used as string?

Hyperion
  • 2,515
  • 11
  • 37
  • 59

1 Answers1

2

I think this answer is interesting to you: https://stackoverflow.com/a/25822886/1406798

Javascript represents its numbers as double precision floats which limits the largest integer number that can be represented to +-9007199254740992.

So if your number can be higher/lower than this value you need to transfer them as strings.

Community
  • 1
  • 1
Tóth Tibor
  • 1,526
  • 12
  • 21