Learning center

Your JSON payload changed before it reached the bug report

Attach the raw bytes of a failing payload, and treat any pretty-printed copy as a view. Formatters and parsers change large integers, decimals and repeated keys without an error.

The same input through four tools#

The input is {"id":9007199254740993,"p":1.10,"a":2,"a":3}.

Toolidpa
jq -c ., version 1.790071992547409931.103
jq -c '.id+0', version 1.79007199254740992
Node 24, JSON.parse then JSON.stringify90071992547409921.13
Python 3.12, json.loads then json.dumps90071992547409931.13

The ID is one above 2 to the power of 53, the first integer a double cannot hold. Node loses it. jq 1.7 keeps the literal text as long as no arithmetic touches it, and loses it when one does. Other jq versions can differ, so check jq --version with the sender.

All of them keep the last a. RFC 8259 says that when names within an object are not unique, "the behavior of software that receives such an object is unpredictable". RFC 8259 If the bug is that two services disagree about a duplicate key, the pretty-printed payload shows no duplicate at all.

Capture before parsing#

curl -sS -o body.bin -D headers.txt -w '%{http_code}\n' https://api.example.com/orders/7
sha256sum body.bin

-o writes the body as received, after any decompression that you asked for. Read it with xxd body.bin | head when an invisible character is possible.

To replay the request, send the file and not the text:

curl -sS -H 'content-type: application/json' --data-binary @request.bin URL

--data @file strips carriage returns and newlines, which changes a signed body. --data-binary does not.

Find whether a tool already changed it#

SignWhat it suggests
A 16-digit or longer ID ending in an even digit or 0A pass through doubles
Money without its trailing zeroParsed and written again
Keys in alphabetical orderA formatter with sorting on
Curly quotes, or a non-breaking spaceA chat or document editor
No trailing newline where the server sends oneA copy from a browser panel

Each sign has innocent explanations: half of all large IDs are even. The comparison that decides is the hash against a capture at the source.

Decide what to hand over#

If the question is about a value, a formatted excerpt with the field is enough, with the raw file beside it. If it is about a signature, a duplicate key, number handling or encoding, only the raw bytes will do. If the payload holds personal data, build a synthetic one that still fails, and keep the shape that matters: the same number of digits, the same duplicate.

Worked example#

This example is fictional. A partner reports that order 9007199254740992 does not exist. Support confirms that it does not. The partner's ticket was pasted from a log viewer that parses JSON in JavaScript. The raw file in their queue has …993, and that order exists. The actual bug is in the partner's consumer, which fetches by the parsed number. Sending IDs as strings would remove the failure on both sides, and that is an API decision to make separately.

In application code, the same loss is described in 64-bit IDs in JavaScript. Return to handing over evidence.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading