Skip to content
Wade Womersley

wade.one

wade womersley – york based software engineer

  • Home
  • 2026
  • November
  • 21
  • Large JSON IDs Should Survive the Trip to the Browser

Large JSON IDs Should Survive the Trip to the Browser

Posted on November 21, 2026 By
Programming

An identifier should come back from the browser with the same digits it had when it left the server. That is a fairly modest requirement, but a large database integer sent as a JSON number can make it surprisingly easy to break. The value can be valid in storage and valid JSON while a client represents it imprecisely.

The JSON specification’s number guidance identifies the integer range from -9,007,199,254,740,991 to 9,007,199,254,740,991 as exactly interoperable for implementations using common binary64 number handling. JavaScript’s ordinary number representation has that safe-integer boundary. A backend using 64-bit integers can therefore accept identifiers outside the range a typical browser client safely handles as numbers.

For an opaque ID that might exceed that boundary, I prefer a string in the API contract. The client needs to keep it, compare it and send it back; arithmetic is usually irrelevant. Make that decision before the large values arrive and carry it through schemas, generated clients, URLs and stored frontend state. Converting the parsed number into a string afterwards cannot recover digits that have already been lost. A special parser may preserve them, but every consumer then needs to understand that arrangement.

I would test one identifier above the safe-integer boundary through the actual serializer and client parser, then check the value sent on a subsequent request. Small fixture IDs will never show this problem. If an existing API needs changing, treat the move from number to string as a contract change and plan for its consumers. It is an annoying detail to discover late, especially when the screen still displays something that looks perfectly reasonable.

Share:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Reddit (Opens in new window) Reddit

Related

Comments

comments

Tags: api javascript json

Post navigation

❮ Previous Post: Database Connection Pools Need a Budget Across Every Instance

You may also like

News
Windows 10 coming to Raspberry Pi 2 – free!
February 2, 2015
Programming
PHP FUNdamentals
September 1, 2009
Programming
Hashed Asset Names Make CDN Releases Easier to Reason About
October 21, 2026
Ego-centric
Heterogeneous Parallel Programming – Completed and Certified!
May 15, 2015
  • AI
  • artificial intelligence
  • Ego-centric
  • Events
  • Films
  • Food
  • Gaming
  • Gym
  • Hardware
  • Holidays
  • News
  • PHP
  • Programming
  • Random Stuff
  • Reviews
  • Science
  • SEO
  • Software
  • Software Engineer
  • Support
  • Uncategorized
  • Work

Copyright © 2026 wade.one.

Theme: Oceanly News Dark by ScriptsTown