@keupoz/tson
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

TSON

TypeScript JSON validator inspired by Google's GSON from Java.

Why?

There is a lot of JSON validators for TypeScript but they are either based on predefined schema or have no runtime check and just rely on type casting hoping the input is always correct.

Installation

This library is available as NPM package:

npm install @keupoz/tson

Usage

All you need is just to call the function that transforms the input to corresponding Json classes and returns a JsonElement:

import { createJsonElement } from "@keupoz/tson";

const element = createJsonElement({ a: 1, b: { c: 2 }, d: 3 });

You can also parse a stringified json object and immediately transform it:

import { parseJson } from "@keupoz/tson";

const element = parseJson("{ a: 1, b: { c: 2 }, d: 3 }");

All methods of JsonElement and other classes should be intuitive and are similar to their GSON alternatives.

Readme

Keywords

Package Sidebar

Install

npm i @keupoz/tson

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

23.7 kB

Total Files

7

Last publish

Collaborators

  • keupoz