smartjson/README.md

57 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2017-02-27 14:35:43 +00:00
# smartjson
2018-07-23 22:38:54 +00:00
2017-02-27 14:35:43 +00:00
typed json handlers
## Availabililty
2018-07-23 22:38:54 +00:00
2017-02-27 14:35:43 +00:00
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartjson)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartjson)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartjson)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartjson/)
## Status for master
2018-07-23 22:38:54 +00:00
2017-02-27 14:35:43 +00:00
[![build status](https://GitLab.com/pushrocks/smartjson/badges/master/build.svg)](https://GitLab.com/pushrocks/smartjson/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartjson/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartjson/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartjson.svg)](https://www.npmjs.com/package/smartjson)
[![Dependency Status](https://david-dm.org/pushrocks/smartjson.svg)](https://david-dm.org/pushrocks/smartjson)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartjson/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartjson/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartjson/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartjson)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
2018-07-23 22:38:54 +00:00
2017-02-27 14:35:43 +00:00
Use TypeScript for best in class instellisense.
### Classes
2018-07-23 22:38:54 +00:00
2017-02-27 14:35:43 +00:00
SmartJson makes it easy to fold and enfold classes into and from JSON
```javascript
2018-07-23 22:38:54 +00:00
import { Foldable, foldDec } from 'smartjson';
2017-02-27 14:35:43 +00:00
class AwesomeClass extends Foldable {
2018-07-23 22:38:54 +00:00
computedValue: string;
2017-02-27 14:35:43 +00:00
@foldDec() // mark anotherValueToStore as foldable
2018-07-23 22:38:54 +00:00
anotherValueToStore: string = null;
constructor() {
super(); // this is important
2017-02-27 14:35:43 +00:00
}
}
2018-07-23 22:38:54 +00:00
let myAwesomeInstance = new AwesomeClass();
let foldedObject = myAwesomeInstance.foldToObject(); // will return {anotherValueToStore: null}
myAwesomeInstance.enfoldFromObject({ anotherValueToStore: 'hi' });
foldedObject = myAwesomeInstance.foldToObject(); // will return {anotherValueToStore: 'hi'}
2017-02-27 14:35:43 +00:00
```
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
2018-07-23 22:38:54 +00:00
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
2017-02-27 14:35:43 +00:00
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)