API Design · Junior · Question 22 of 75
Why might an API return large numeric IDs as strings in JSON?
- 1JSON doesn't support numbers
- ✓Correct answer: JavaScript numbers lose precision above 2^53, so 64-bit IDs can be silently corrupted in browsers
- 3Strings are smaller than numbers
Explanation
Twitter-style 64-bit IDs are a classic example. Clients shouldn't do math on IDs anyway.