@@ -42,7 +42,7 @@ export class ObjectSerializer {
42
42
/**
43
43
* Serilize object to json string.
44
44
*/
45
- public static serialize ( data : any , type : string ) {
45
+ public static serialize ( data : any , type : string , isRecursiveCall : boolean = false ) {
46
46
if ( data === undefined ) {
47
47
return data ;
48
48
} else if ( primitives . indexOf ( type . toLowerCase ( ) ) !== - 1 ) {
@@ -54,12 +54,13 @@ export class ObjectSerializer {
54
54
for ( const index in data ) {
55
55
if ( data . hasOwnProperty ( index ) ) {
56
56
const date = data [ index ] ;
57
- transformedData . push ( ObjectSerializer . serialize ( date , subType ) ) ;
57
+ transformedData . push ( ObjectSerializer . serialize ( date , subType , true ) ) ;
58
58
}
59
59
}
60
60
return transformedData ;
61
61
} else if ( type === "Date" ) {
62
- return new Date ( data ) ;
62
+ const result = data . toISOString ( ) as string ;
63
+ return isRecursiveCall ? result : "\"" + result + "\"" ; ;
63
64
} else {
64
65
if ( enumsMap [ type ] ) {
65
66
return data ;
@@ -74,7 +75,7 @@ export class ObjectSerializer {
74
75
for ( const index in attributeTypes ) {
75
76
if ( attributeTypes . hasOwnProperty ( index ) ) {
76
77
const attributeType = attributeTypes [ index ] ;
77
- instance [ attributeType . baseName ] = ObjectSerializer . serialize ( data [ attributeType . name ] , attributeType . type ) ;
78
+ instance [ attributeType . baseName ] = ObjectSerializer . serialize ( data [ attributeType . name ] , attributeType . type , true ) ;
78
79
}
79
80
}
80
81
return instance ;
0 commit comments