jerialize
v1.0.12
Published
A Typescript json (de)serializer
Downloads
8
Readme
#Jerialize
Preperation
Nodejs:
npm install jerialize --save
Systemjs:
jspm install npm:jerialize
Usage
import * as jerialize from "jerialize";
class MyClass{
@jerialize.serialize()
public simpleProperty: string;
@jerialize.serialize()
public simpleArray: Array<string>;
@jerialize.serialize({type: AnotherClass}) //Providing the type is required
public objectProperty: AnotherClass;
@jerialize.serialize({type: AnotherClass}) //Providing the type is required, arrays are autodetected
public objectArray: Array<AnotherClass>;
constructor(){ // The constructor has to be without parameters or each parameter has to be optional
...
}
}
var jerializer.Serializer = new jerializer.Serializer();
var testObj: MyClass = new MyClass();
//fill the fields of testObj
var serialized: string = <string>serializer.serialize(testObj,true);
var deserialized: MyClass = serializer.deserialize<MyClass>(MyClass,serialized);