Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 575 Bytes

README.md

File metadata and controls

34 lines (23 loc) · 575 Bytes

OVERVIEW

For mapping from server returned JSON to TypeScript defined class. The idea is inspired by json-typescript-mapper.

INSTALL

npm install json-ts-mapper --registry=http://npmjs.gagogroup.cn --save

EXAMPLE

class User {
  @JsonProperty({ name: "object.uid.id" })
  id: number;

  @JsonProperty()
  username: string;
}

const userResponse: any = {
  object: {
    uid: {
      id: 3
    }
  },
  username: "franklin"
};

const user: User = ObjectMapper.deserialize(User, userResponse);