ts-jsonify
A simple typescript/json Serializer and deserializer. It allows to configure the mapping through annotations.
Installation
npm i --save ts-jsonify
Usage
;user.email = 'example@test.com';user.options.set'vip', true;user.clientSideOptions.push"new-user"; // ... // this object can be used for example to send within an angular service via http; this.http.post'/users', userDto.subscribe
Undefined and null handling
When deserializing, json null will be treated as javascript null, whereas properties that are not available in the json will be ignored and default value is kept.
When serializing
Custom Converters
You can create your own converters for any property. It must implement the IConverter interface.
;console.logjsonObj.name;// "HANS"
Known Issues
Non initialized Properties
Due to the concept how TsJsonify works, it can only assign properties that are initialized after instantiating the object, it can be initialized with undefined though.