?, and null do to a signed payment payloadAn x402 payment intent is signed over bytes. The verifier receives a document and must decide whether those bytes are the ones that were signed. There are two ways to do that, and they disagree exactly when it matters:
null and "" โ is lost before the digest is computed, and the verifier cannot tell that it happened.The second approach is the common one, because it is easier to write. Below is what the three parsers a checker is most likely to be built on actually do with the cases that separate the two approaches. Everything was run on the current releases โ Node, CPython, and Go 1.26 โ and every output quoted here is a copy of what the command printed.
RFC 8259 says object names should be unique and does not say what a parser must do when they are not. In practice all three parsers accept the document and keep the last value:
input: {"url":"a","url":"b"}
Node JSON.parse(input) -> { url: "b" }
CPython json.loads(input) -> {'url': 'b'}
Go json.Unmarshal(input, &map[string]any{}) -> map[url:b]
None raises. But "the value is gone" is only true if you require the parser to hand you a finished object. Two of the three standard libraries will show you the pair if you ask during decoding:
CPython
json.loads(input, object_pairs_hook=lambda pairs: pairs)
-> [('url', 'a'), ('url', 'b')]
Go
dec := json.NewDecoder(strings.NewReader(input))
for { tok, err := dec.Token(); if err != nil { break }; ... }
-> { url a url b }
Node is the outlier. Its reviver is invoked once per surviving member, so for the input above it receives "b" and never sees "a":
JSON.parse('{"url":"a","url":"b"}', (k, v) => { seen.push([k, v]); return v })
-> [["url","b"], ["", {"url":"b"}]] // one url, one root โ not two urls
The consequence for a fixture row is concrete. A rule "duplicate url is rejected" can be enforced at decode time with the standard library in CPython and Go, but in Node it needs a duplicate-detecting reader over the raw buffer. A row that says reject at the parser is untestable in Node; a row that says reject somewhere does not distinguish a checker that rejects before the loss from one that rejects after it, where rejection is no longer possible on the original value.
duplicate_present (the bytes contain two members with the same name) versus duplicate_rejected_at_decode (the checker rejected before the object existed). The first is a property of the input; the second is a property of the implementation.? survives some rebuilds and not othershttps://x/v1/data and https://x/v1/data? are different byte strings and, under a verbatim rule, different identities. Whether a checker can still see the difference depends on whether it hashes the received text or a re-serialized URL:
node: new URL("https://x/v1/data?")
.href -> "https://x/v1/data?" // ? kept
.search -> "" // indistinguishable from no query
.origin + .pathname + .search -> "https://x/v1/data" // ? dropped
python: urlsplit("https://x/v1/data?").geturl() -> "https://x/v1/data" // ? dropped
go: url.Parse("https://x/v1/data?")
.ForceQuery true, .String() -> "https://x/v1/data?" // ? kept
Three languages, three behaviors, one document. A signer that hashes the literal bytes and a checker that hashes origin + pathname + search will disagree on exactly this input, silently, because both see an empty query. The practical rule that falls out: the digest must be taken over the received buffer, not over any re-serialization of it.
null, "" and a missing name are three cases, and a typed decoder collapses two of themThis is the case where the choice of decode target, not the JSON document, decides the answer. With Go's typed decoder, an explicit null is not an error โ it is a silent zero value:
type S struct{ URL string `json:"url"` }
{"url":null} -> URL == "", err == nil
{"url":42} -> URL == "", err == json: cannot unmarshal number into Go struct field S.url of type string
{"url":""} -> URL == "", err == nil
type P struct{ URL *string `json:"url"` }
{"url":null} -> URL == nil
{"url":""} -> URL points at ""
A checker that validates after decoding into string therefore cannot tell an unset variable from an explicit empty string โ the information was destroyed by the decoder, not by the document. With a pointer the two are distinguishable, but an absent name also decodes to nil, so absent and null collapse instead. To keep all three apart, decode the raw member (json.RawMessage, or a map[string]json.RawMessage) and decide presence before typing.
Node and CPython preserve the distinction throughout: JSON.parse yields null and json.loads yields None, neither equal to "".
Even with no duplicate names and no null, a rebuild changes bytes because map iteration does not:
input: {"b":1,"a":2}
Go json.Marshal(map[string]any{...}) -> {"a":2,"b":1} // keys sorted
Node JSON.stringify(JSON.parse(input)) -> {"b":1,"a":2} // insertion order
Python json.dumps(json.loads(input)) -> {"b":1,"a":2} // insertion order
Same document, two byte strings. This is the reason to publish canonical_bytes alongside a digest: "same hash" then means the same bytes, not the same value under one runtime's serializer.
null-vs-"" row each test a different side of that line.None of this is exotic input. An unset variable that renders as "", a URL rebuilt from a parsed object, a config merged twice โ each produces exactly the documents above. The question is only whether the verifier hashed what arrived or what its parser left of it.