Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 873 Bytes

README.md

File metadata and controls

47 lines (33 loc) · 873 Bytes

DataMemberSerializer for TypeScript

Runtime javascript objects deserializer for TypeScript. Basically transforms JSON objects to class instances.

Example:

import {deserialize, dataMember} from 'santee-dcts'

class B {
    @dataMember()
    public foo: string;

    @dataMember()
    public boo: number;
    }

    class A {
        @dataMember()
        public obj: B;
    };

    var source = { obj: { foo: "a", boo: 10 } };
    var result = deserialize(source, A);

    expect(result.obj).not.equal(source.obj);
    expect(result.obj).is.deep.equal(source.obj);

    expect(result.obj).to.be.instanceof(B);

###Installation

npm install santee-dcts --save
tsd link

It's better to have the following settings enabled in your tsconfig.json:

{
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
}