0.2.1 • Published 1 year ago

@mellkam/json v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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
0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago