Skip to content

santee/santee-dcts

Repository files navigation

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
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published