Skip to content

json-literal ​

A constant marked /** @json */ whose value isn't plain data that JSON keeps exactly.

Why: @json replaces the literal with JSON.parse("...") to load it faster. That is only the same value when nothing is lost on the way: -0 becomes 0, NaN and Infinity don't exist in JSON, and a "__proto__" key becomes an own property instead of setting the prototype. Guide: Adopting SAFE-TS.

✕ Rejectedjson-literal
ts
/** @json */
export const limits = { low: -0, high: 10 };
✓ Accepted0 diagnostics
ts
/** @json */
export const limits = { low: 0, high: 10 };
ts
/** @json */
export const limits = JSON.parse("{\"low\":0,\"high\":10}");

@json goes on a single module-level const. Its value may contain strings, finite numbers, booleans, and arrays and objects of them with plain keys (no spreads, computed keys, methods or shorthand properties).

MIT OR Apache-2.0 · Docs by Gemini 4 Neon Extra