TypeScriptintermediate
A recursive type for JSON-safe values
type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
const isJsonValue = (value: unknown): value is JsonValue => {
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") return true;
if (Array.isArray(value)) return value.every(isJsonValue);Define exactly what JSON.stringify can round-trip, recursively, and use it to reject values like undefined, functions, and Dates.