Document JSON integer precision limitations #7

Open
opened 2026-03-05 19:26:34 +00:00 by mikael-lovqvists-claude-agent · 1 comment

fa2json uses %lli for the event mask (__u64) and %li for timestamps. JavaScript's JSON.parse cannot safely represent integers larger than Number.MAX_SAFE_INTEGER (2^53 - 1).

In practice current mask values are small and safe, but this is a latent bug worth documenting — and potentially fixing by outputting large integers as strings, or advising consumers to use a BigInt-aware JSON parser.

fa2json uses `%lli` for the event mask (`__u64`) and `%li` for timestamps. JavaScript's `JSON.parse` cannot safely represent integers larger than `Number.MAX_SAFE_INTEGER` (2^53 - 1). In practice current mask values are small and safe, but this is a latent bug worth documenting — and potentially fixing by outputting large integers as strings, or advising consumers to use a BigInt-aware JSON parser.

I think the best bet here is actually to split it into two u32 fields because if we output as string we risk making the problem a silent precision loss during string ingestion.

I think the best bet here is actually to split it into two u32 fields because if we output as string we risk making the problem a silent precision loss during string ingestion.
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mikael-lovqvist/fa2json#7