By Relwick · Published
A database can store an identifier correctly while a browser silently receives a different numeric value.
A resume entry should trace the precision loss across the serialization boundary and explain the contract that prevented it.
Quick answer & key takeaways
Identify the large identifier or count that changed when a JSON number became a JavaScript Number. Explain the agreed representation used across the API and client, and verify exact round trips with boundary values. Keep identifiers as identifiers when arithmetic is unnecessary. Converting an already rounded Number into a string or BigInt cannot reconstruct digits that were lost during parsing.
- Check the value before and after JSON parsing.
- Preserve exact representation through every relevant conversion.
- Treat API type changes as compatibility decisions.
Locate the first loss of digits
Compare the source value, serialized response text, parsed client value, and any value sent back to the server. This identifies whether the loss happened in storage, serialization, parsing, or a later coercion. Do not blame display formatting without checking the actual value.
MDN explains that JSON numbers are converted to JavaScript numbers before an ordinary reviver handles the parsed value, potentially losing precision. It discusses lossless representations such as strings and access to source text in supported runtimes. Describe the approach actually supported by your clients.
Define the data contract
| Field purpose | Contract question |
|---|---|
| Opaque identifier | Can it remain an exact string without numeric coercion? |
| Large count used in arithmetic | Which supported representation preserves the required range? |
| Existing API consumer | How does it handle a changed response type? |
| Round-trip request | Does the server receive the exact intended value? |
Keep field-specific validation. Changing every numeric field to a string can create unrelated compatibility problems, while treating every digit string as arithmetic can damage identifiers. Explain the narrow contract chosen for the affected field.
Write the fix with exactness evidence
A fictional bullet is: “Preserved large record identifiers across JSON responses and browser requests by aligning the API type contract and adding exact round-trip regression tests.” It describes the lost-identity problem without claiming a general arithmetic redesign.
Use synthetic values around the relevant representable boundary and verify equality against the original text or exact type. Include values that previously collapsed to the same Number. A screenshot of a formatted field is weaker evidence than a test of the value used in the next request.
Document compatibility handling for existing consumers. If the work involved a versioned endpoint or a gradual client update, state that scope. Do not describe a development-only change as a deployed repair for every stored or transmitted identifier.
Prepare a small before-and-after trace
A compact table can show the raw JSON representation, parsed type, and returned value using invented identifiers. Keep production IDs out of public material. Explain why conversion after the first precision loss cannot recover the original digits.
Add the entry in Resume Studio with the data boundary, contract decision, and regression evidence. Keep decimal rounding work separate; this contribution is about exact large integers and identity across serialization.
Frequently asked questions
Can string conversion recover digits after Number parsing rounded them?
No. Preserve the exact representation before the lossy conversion occurs.
Must every identifier be used as a number?
No. An opaque identifier can often remain a validated string when arithmetic is unnecessary.
Is changing a JSON field type a compatibility concern?
Yes. Verify the consumers and rollout scope rather than assuming they accept the new representation.
Sources and further reading
- MDN: JSON.parse and precision — Explains precision loss during number parsing and approaches that preserve exact source values.
Summary
Show where the digits changed and how the API contract preserved them. Exact round-trip evidence makes the fix concrete.