1- import { Constants , getJsonIgnoreDecorator , getJsonPropertyDecorator , getPropertyDecorator } from './ReflectHelper' ;
1+ import {
2+ Constants ,
3+ getJsonIgnoreDecorator ,
4+ getJsonPropertyDecorator ,
5+ getPropertyDecorator ,
6+ } from "./ReflectHelper" ;
27
38/**
49 * Decorator names
510 */
6- export const JSON_PROPERTY_DECORATOR_NAME = ' JsonProperty' ;
11+ export const JSON_PROPERTY_DECORATOR_NAME = " JsonProperty" ;
712// const JSON_IGNORE_DECORATOR_NAME = 'JsonIgnore';
813
914/**
1015 * Decorator metadata definition for JsonProperty
1116 */
1217export interface JsonPropertyDecoratorMetadata {
13- name ?: string ; // name of the JSON property to map
14- required ?: boolean ; // is this field required in the JSON object that is being deserialized
15- access ?: AccessType ; // is this serializable and de-serializable
16- type ?: any ; // the type of Object that should be assigned to this property
17- serializer ?: any ; // Serializer for the type
18- deserializer ?: any ; // deserializer for the type
18+ name ?: string ; // name of the JSON property to map
19+ required ?: boolean ; // is this field required in the JSON object that is being deserialized
20+ access ?: AccessType ; // is this serializable and de-serializable
21+ type ?: any ; // the type of Object that should be assigned to this property
22+ serializer ?: any ; // Serializer for the type
23+ deserializer ?: any ; // deserializer for the type
1924}
2025
2126export enum AccessType {
22- READ_ONLY , WRITE_ONLY , BOTH
27+ READ_ONLY ,
28+ WRITE_ONLY ,
29+ BOTH ,
2330}
2431
2532export interface Serializer {
26- serialize ( value : any ) : any ;
33+ serialize ( value : any ) : any ;
2734}
2835
2936export interface Deserializer {
30- deserialize ( value : any ) : any ;
37+ deserialize ( value : any ) : any ;
3138}
3239
3340/**
3441 * JsonProperty Decorator function.
3542 */
36- export const JsonProperty = ( metadata ?: JsonPropertyDecoratorMetadata | string ) : any => {
37- if ( typeof metadata === 'string' ) {
38- return getJsonPropertyDecorator ( { name : metadata as string , required : false , access : AccessType . BOTH } ) ;
39- } else {
40- return getJsonPropertyDecorator ( metadata ) ;
41- }
43+ export const JsonProperty = (
44+ metadata ?: JsonPropertyDecoratorMetadata | string
45+ ) : any => {
46+ if ( typeof metadata === "string" ) {
47+ return getJsonPropertyDecorator ( {
48+ name : metadata as string ,
49+ required : false ,
50+ access : AccessType . BOTH ,
51+ } ) ;
52+ } else {
53+ return getJsonPropertyDecorator ( metadata ) ;
54+ }
4255} ;
4356
4457/**
@@ -50,31 +63,31 @@ export const JsonProperty = (metadata?: JsonPropertyDecoratorMetadata | string):
5063 * @returns
5164 */
5265export const CacheKey = ( key : string ) : Function => {
53- return ( f : Function ) => {
54- const functionName = ' getJsonObjectMapperCacheKey' ;
55- const functionImpl = new Function ( `return '${ key } ';` ) ;
56- f [ functionName ] = functionImpl ;
57- } ;
66+ return ( f : Function ) => {
67+ const functionName = " getJsonObjectMapperCacheKey" ;
68+ const functionImpl = new Function ( `return '${ key } ';` ) ;
69+ f [ functionName ] = functionImpl ;
70+ } ;
5871} ;
5972
6073/**
6174 * JsonIgnore Decorator function.
6275 */
6376export const JsonIgnore = ( ) : Function => {
64- return getJsonIgnoreDecorator ( ) ;
77+ return getJsonIgnoreDecorator ( ) ;
6578} ;
6679
6780/**
6881 * Json convertion error type.
6982 */
7083export class JsonConverstionError {
71- private json : string ;
72- private message : string ;
73- private stack : string ;
84+ private json : string ;
85+ private message : string ;
86+ private stack : string ;
7487
75- constructor ( message : string , json : string ) {
76- this . json = json ;
77- this . message = message ;
78- this . stack = ( new Error ( ) ) . stack ;
79- }
88+ constructor ( message : string , json : string ) {
89+ this . json = json ;
90+ this . message = message ;
91+ this . stack = new Error ( ) . stack ;
92+ }
8093}
0 commit comments