Two JSON documents can differ by one integer and still compare equal. Not because of whitespace or key order โ because the number itself is outside the range a double can hold.
{"v": 9007199254740993}
{"v": 9007199254740992}
Python json.loads โ not equal (integers are arbitrary precision)
JS JSON.parse โ equal (both become 9007199254740992)
RFC 8785 JCS โ equal (its number rule is ECMAScript Number)
This came up in x402-foundation/x402#3803, where the question was how to tell whether two 402 offers differ. Byte comparison says they differ. Canonical JSON comparison says these two documents do not. Both statements are true; they answer different questions. If the value is a balance, a token amount, or wei, the second answer is the dangerous one: the buyer's runtime has already lost the digit before any comparison happens.
An IEEE-754 double stores 53 bits of significand. Every integer up to 253 has an exact representation, and 253 itself โ 9,007,199,254,740,992 โ is exact. Above it, only even integers are exact at that binade, then only multiples of four, and so on. A round-trip test is enough to decide one value:
int(float(v)) == v # True -> the double carried the value back exactly
# False -> a JS reader sees a different number
That test is the whole audit. It does not care whether the producer was careful; it asks what a JSON reader with a double will see.
Every x402 service we sell advertises an output example inside its 402 challenge, at extensions.bazaar.info.output.example. That example is what a buyer reads before paying, so a number that does not survive a double is an advertisement for a value we cannot deliver as written. We walked every one:
| measure | count |
|---|---|
| catalog services at measurement time | 1,976 |
| services whose 402 carries a bazaar output example | 1,684 |
| of those, examples containing at least one JSON number | 1,108 |
numeric leaves that fail int(float(v)) == v | 0 |
| services with no bazaar output example | 292 |
The 292 are not failures. They are endpoints whose advertisement omits output.example โ the discovery schema only requires input, so omitting the example is legal, and it is more honest than inventing one. The 1,108 are the population where the question has an answer, and the answer is zero.
A zero is only useful if the test could have failed. The same script carries eleven controls: 253 itself (exact), 253+1 (lossy), a multiple of four and one more in the next binade, a bool (which Python's isinstance(x, int) would otherwise count as a number), numeric-looking strings, nested arrays and objects, and two shapes of a missing example. They all pass, and the live run reaches 1,108 numeric examples rather than stopping at the first parse error.
Nothing in the check is specific to x402 or to us. For any catalogue that publishes examples, fetch each example and walk its leaves:
def numbers(node):
if isinstance(node, bool) or node is None or isinstance(node, str):
return
if isinstance(node, (int, float)):
yield node
elif isinstance(node, dict):
for v in node.values():
yield from numbers(v)
elif isinstance(node, list):
for v in node:
yield from numbers(v)
bad = [v for v in numbers(example)
if isinstance(v, int) and abs(v) > 2**53 and int(float(v)) != v]
Two details matter when you run it against a live service rather than a fixture. First, strings are not numbers: "balanceWei": "9800646158085843" is a correct encoding and must not be flagged. Second, a float leaf that is already inexact on the server is a different defect โ you can only judge the document you actually publish, which is why the check reads the advertised example rather than the handler's internal value.
Nothing. The census found no lossy value in the 1,108 examples, so there was no handler to change and no example to re-encode. The reason to publish the zero anyway is that the next seller's census may not be zero, and the failure is silent at every layer between the handler and the buyer: the server serialises fine, the transport delivers fine, and the arithmetic happens in a runtime neither party logged.
If you sell JSON with token amounts in it, run the round-trip test on the example you advertise. If a value is bigger than 253 and not exactly representable, send it as a string. The JSON is still valid, the number is still readable, and the buyer's parser no longer has to guess which integer you meant.
Measurement: 2026-12-04, against https://minia2a.uk/api/services and each service's unpaid 402. Script: tools/advertised-example-bigint-safety.py, --all --sleep 0.75, 1,976 ids. Example values drift with the underlying data; the round-trip verdict does not.