JSON source text access
The JSON.isRawJSON() static method tests whether a value is an object returned by JSON.rawJSON().
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 114 | 114 | 135 | 18.4 | 114 | 18.4 | |
| Built-in object | ||||||
| If a reviver is specified, the value computed by parsing is transformed before being returned. Specifically, the computed value and all its properties (in a depth-first fashion, beginning with the most nested properties and proceeding to the original value itself) are individually run through the reviver. | 114 | 114 | 135 | 18.4 | 114 | 18.4 |
| The JSON.rawJSON() static method creates a "raw JSON" object containing a piece of JSON text. When serialized to JSON, the raw JSON object is treated as if it is already a piece of JSON. This text is required to be valid JSON. | 114 | 114 | 135 | 18.4 | 114 | 18.4 |
Syntax
JSON.parse('{"big": 12345678901234567890}', (key, value, { source }) => {
if (key === 'big') return BigInt(source);
return value;
}); Live demo
Check JSON.rawJSON support
Detect the API and fall back when the runtime does not support it yet.
Embed pre-serialized JSON
Insert a prebuilt JSON fragment without double-encoding it.
Compare with a normal string
See the difference between raw JSON insertion and a plain string field.
Use cases
-
Precision-sensitive numbers
Retain the exact numeric source text when downstream logic must avoid precision loss.
-
Audit-friendly parsing
Compare parsed values with the original token text when traceability matters.
Cautions
- This is a niche parsing feature, so avoid it unless exact source preservation solves a real problem.
- Extra parsing complexity is rarely justified for everyday configuration or API payloads.
Accessibility
- No direct accessibility effect, but reliable data handling supports accurate user-facing output.
- Keep specialized parsing code well documented so future contributors can maintain it confidently.