2019-02-14 23:16:34 +01:00
|
|
|
# @pushrocks/smartjson
|
2017-02-27 15:35:43 +01:00
|
|
|
typed json handlers
|
|
|
|
|
2019-02-14 23:16:34 +01:00
|
|
|
## Availabililty and Links
|
|
|
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartjson)
|
|
|
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartjson)
|
|
|
|
* [github.com (source mirror)](https://github.com/pushrocks/smartjson)
|
|
|
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartjson/)
|
2017-02-27 15:35:43 +01:00
|
|
|
|
|
|
|
## Status for master
|
2019-02-14 23:16:34 +01:00
|
|
|
[](https://gitlab.com/pushrocks/smartjson/commits/master)
|
|
|
|
[](https://gitlab.com/pushrocks/smartjson/commits/master)
|
|
|
|
[](https://www.npmjs.com/package/@pushrocks/smartjson)
|
|
|
|
[](https://snyk.io/test/npm/@pushrocks/smartjson)
|
|
|
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
|
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
2019-07-04 17:04:24 +02:00
|
|
|
[](https://prettier.io/)
|
2017-02-27 15:35:43 +01:00
|
|
|
|
|
|
|
## Usage
|
2018-07-24 00:38:54 +02:00
|
|
|
|
2017-02-27 15:35:43 +01:00
|
|
|
Use TypeScript for best in class instellisense.
|
|
|
|
|
|
|
|
### Classes
|
2018-07-24 00:38:54 +02:00
|
|
|
|
2017-02-27 15:35:43 +01:00
|
|
|
SmartJson makes it easy to fold and enfold classes into and from JSON
|
|
|
|
|
|
|
|
```javascript
|
2019-02-14 23:16:34 +01:00
|
|
|
import { Smartjson, foldDec } from 'smartjson';
|
|
|
|
|
|
|
|
class AwesomeClass extends Smartjson {
|
2019-07-04 17:04:24 +02:00
|
|
|
static stringify;
|
2017-02-27 15:35:43 +01:00
|
|
|
|
2018-07-24 00:38:54 +02:00
|
|
|
computedValue: string;
|
2017-02-27 15:35:43 +01:00
|
|
|
|
|
|
|
@foldDec() // mark anotherValueToStore as foldable
|
2018-07-24 00:38:54 +02:00
|
|
|
anotherValueToStore: string = null;
|
|
|
|
constructor() {
|
|
|
|
super(); // this is important
|
2017-02-27 15:35:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-24 00:38:54 +02: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 15:35:43 +01:00
|
|
|
```
|
|
|
|
|
2019-02-14 23:16:34 +01:00
|
|
|
For further information read the linked docs at the top of this readme.
|
2017-02-27 15:35:43 +01:00
|
|
|
|
|
|
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
2019-02-14 23:16:34 +01:00
|
|
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
2017-02-27 15:35:43 +01:00
|
|
|
|
2019-02-14 23:16:34 +01:00
|
|
|
[](https://maintainedby.lossless.com)
|