Skip to content

Server returned JSON to TypeScript interface or class

Notifications You must be signed in to change notification settings

DaYeSquad/json-ts-mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

Server returned JSON to TypeScript interface or class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published