Skip to content

Converters

Michael Dostál edited this page Nov 14, 2018 · 3 revisions

Every converter needs to implement PropertyConverter interface

export interface PropertyConverter {
  mask(value: any): any;
  unmask(value: any): any;
}

Example:

class ValueConverter implements PropertyConverter{
   mask(value:any){
       // your logic for deserialization
   }

   unmask(value:any){
       // your logic for serialization
   }
}

Converters can be used in @Attribute, @NestedAttribute and @JsonAttribute decorators like this:

@Attribute({converter: new ValueConverter()}
value:any;
Clone this wiki locally