1.0.5 • Published 4 years ago

ts-json-decoder v1.0.5

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Typescript JSON Decoder

The typescript library that helps to decode and check raw json with types.

Install

npm install ts-json-decoder

Example

import { decodeObject, decodeBoolean, decodeNumber, decodeString } from 'ts-json-decoder';

const userData = {
    name: 'Joe',
    age: 30,
    hasJob: true
}

interface User {
    name: string;
    age: number;
    hasJob: boolean;
}

const result = decodeObject<User>(userData, (data) => ({
    name: decodeString(data.name),
    age: decodeNumber(data.age),
    hasJob: decodeBoolean(data.hasJob),
}));

result
    .then(console.log)
    .catch(console.log)
1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago