11import 'reflect-metadata' ;
2- import { IDecoratorMetaData } from './' ;
32/**
43 * provide interface to indicate the object is allowed to be traversed
54 *
@@ -8,17 +7,30 @@ import { IDecoratorMetaData } from './';
87export interface IGenericObject {
98 [ key : string ] : any ;
109}
10+ /**
11+ * When custom mapping of a property is required.
12+ *
13+ * @interface
14+ */
15+ export interface ICustomConverter {
16+ fromJson ( data : any ) : any ;
17+ toJson ( data : any ) : any ;
18+ }
1119/**
1220 * IDecoratorMetaData<T>
1321 * DecoratorConstraint
1422 *
1523 * @interface
24+ * @property {ICustomConverter } customConverter, will be used for mapping the property, if specified
25+ * @property {boolean } excludeToJson, will exclude the property for serialization, if true
1626 */
1727export interface IDecoratorMetaData < T > {
1828 name ?: string ;
1929 clazz ?: {
2030 new ( ) : T ;
2131 } ;
32+ customConverter ?: ICustomConverter ;
33+ excludeToJson ?: boolean ;
2234}
2335/**
2436 * JsonProperty
@@ -40,3 +52,11 @@ export declare function JsonProperty<T>(metadata?: IDecoratorMetaData<T> | strin
4052export declare function deserialize < T extends IGenericObject > ( Clazz : {
4153 new ( ) : T ;
4254} , json : IGenericObject ) : T ;
55+ /**
56+ * Serialize: Creates a ready-for-json-serialization object from the provided model instance.
57+ * Only @JsonProperty decorated properties in the model instance are processed.
58+ *
59+ * @param instance an instance of a model class
60+ * @returns {any } an object ready to be serialized to JSON
61+ */
62+ export declare function serialize ( instance : any ) : any ;
0 commit comments