santee-dcts
TypeScript icon, indicating that this package has built-in type declarations

0.9.6 • Public • Published

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
}

Readme

Keywords

none

Package Sidebar

Install

npm i santee-dcts

Weekly Downloads

0

Version

0.9.6

License

MIT

Unpacked Size

78.4 kB

Total Files

39

Last publish

Collaborators

  • alexander.shevnin