0.5.1 • Published 12 months ago

json-less v0.5.1

Weekly downloads
2
License
MIT
Repository
github
Last release
12 months ago

JSONLess

Build Status Coverage Status npm version npm

How it works

JSONLess replaces objects like Date into {$type: 'Date', $value : '2016-03-04T07:33:03.000Z'} before value is stringify and after parse it will revive original object instance

Usage

Use it exacly in the same way as regular JSON

stringify

JSONLess.stringify({name : 'object with not scalar values', date : new Date()});
// '{"name":"object with not scalar values","date":{"$type":"Date","$value":"2016-03-04T07:33:03.000Z"}}'

parse

JSONLess.parse('{"name":"object with not scalar values","date":{"$type":"Date","$value":"2016-03-04T07:33:03.000Z"}}');
// { name: 'object with not scalar values', date: Thu Mar 04 2016 08:33:03 GMT+0100 (CET) }

addHandler

JSONLess.addHandler(Date, (cls, value) => {
	return value.toJSON();
}, (cls, value) => {
	return new cls(value);
});

now we have added support for Date type

API docs

See JSONLess github.io pages

0.5.1

12 months ago

0.6.0

12 months ago

0.5.0

5 years ago

0.4.8

5 years ago

0.4.7

6 years ago

0.4.6

6 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.7

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago