0.2.1 • Published 1 year ago
@mellkam/json v0.2.1
Utility types and validators for typesafe work with json in typescript.
Installation
npm i @mellkam/json
Usage
import { type JSONValue, isJSONValue } from "@mellkam/json";
JSON.parse("...") as JSONValue;
JSON.stringify({ ... } as JSONValue)
isJSONValue({ key: "value" }) // true
isJSONValue({ key: new Map() }) // false
In the case of cyclic objects, the validator gets into an infinite loop.
Validator benchmark
594 times faster than zod json schema
zod: 2.523s
@mellkam/json: 4.244ms