@@ -5,7 +5,6 @@ import { Any } from "./any";
55/**
66 * Offers a simple API for mapping JSON objects to TypeScript/JavaScript classes and vice versa.
77 *
8- * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
98 * @see https://www.npmjs.com/package/json2typescript full documentation on NPM
109 */
1110export class JsonConvert {
@@ -32,7 +31,8 @@ export class JsonConvert {
3231 * - OperationMode.DISABLE: json2typescript will be disabled, no type checking or mapping is done
3332 * - OperationMode.ENABLE: json2typescript is enabled, but only errors are logged
3433 * - OperationMode.LOGGING: json2typescript is enabled and detailed information is logged
35- * @returns {number }
34+ *
35+ * @see https://www.npmjs.com/package/json2typescript full documentation
3636 */
3737 get operationMode ( ) : number {
3838 return this . _operationMode ;
@@ -45,7 +45,8 @@ export class JsonConvert {
4545 * - OperationMode.DISABLE: json2typescript will be disabled, no type checking or mapping is done
4646 * - OperationMode.ENABLE: json2typescript is enabled, but only errors are logged
4747 * - OperationMode.LOGGING: json2typescript is enabled and detailed information is logged
48- * @param value
48+ *
49+ * @see https://www.npmjs.com/package/json2typescript full documentation
4950 */
5051 set operationMode ( value : number ) {
5152 if ( value in OperationMode ) this . _operationMode = value ;
@@ -69,7 +70,7 @@ export class JsonConvert {
6970 * - ValueCheckingMode.ALLOW_OBJECT_NULL: objects in the JSON are allowed to be null, primitive types are not allowed to be null
7071 * - ValueCheckingMode.DISALLOW_NULL: no null values are tolerated in the JSON
7172 *
72- * @returns { number }
73+ * @see https://www.npmjs.com/package/json2typescript full documentation
7374 */
7475 get valueCheckingMode ( ) : number {
7576 return this . _valueCheckingMode ;
@@ -83,7 +84,7 @@ export class JsonConvert {
8384 * - ValueCheckingMode.ALLOW_OBJECT_NULL: objects in the JSON are allowed to be null, primitive types are not allowed to be null
8485 * - ValueCheckingMode.DISALLOW_NULL: no null values are tolerated in the JSON
8586 *
86- * @param value
87+ * @see https://www.npmjs.com/package/json2typescript full documentation
8788 */
8889 set valueCheckingMode ( value : number ) {
8990 if ( value in ValueCheckingMode ) this . _valueCheckingMode = value ;
@@ -99,7 +100,7 @@ export class JsonConvert {
99100 * Determines whether primitive types should be checked.
100101 * If true, it will be allowed to assign primitive to other primitive types.
101102 *
102- * @returns { boolean }
103+ * @see https://www.npmjs.com/package/json2typescript full documentation
103104 */
104105 get ignorePrimitiveChecks ( ) : boolean {
105106 return this . _ignorePrimitiveChecks ;
@@ -109,7 +110,7 @@ export class JsonConvert {
109110 * Determines whether primitive types should be checked.
110111 * If true, it will be allowed to assign primitive to other primitive types.
111112 *
112- * @param value
113+ * @see https://www.npmjs.com/package/json2typescript full documentation
113114 */
114115 set ignorePrimitiveChecks ( value : boolean ) {
115116 this . _ignorePrimitiveChecks = value ;
@@ -130,7 +131,8 @@ export class JsonConvert {
130131 * You may assign the following values:
131132 * - PropertyMatchingRule.CASE_STRICT: JSON properties need to match exactly the names in the decorators
132133 * - PropertyMatchingRule.CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
133- * @returns {number }
134+ *
135+ * @see https://www.npmjs.com/package/json2typescript full documentation
134136 */
135137 get propertyMatchingRule ( ) : number {
136138 return this . _propertyMatchingRule ;
@@ -142,47 +144,42 @@ export class JsonConvert {
142144 * You may assign the following values:
143145 * - PropertyMatchingRule.CASE_STRICT: JSON properties need to match exactly the names in the decorators
144146 * - PropertyMatchingRule.CASE_INSENSITIVE: JSON properties need to match names in the decorators, but names they are not case sensitive
145- * @param value
147+ *
148+ * @see https://www.npmjs.com/package/json2typescript full documentation
146149 */
147150 set propertyMatchingRule ( value : number ) {
148151 if ( value in PropertyMatchingRule ) this . _propertyMatchingRule = value ;
149152 }
150153
151154 /**
152- * Determines whether the check for "required" properties should be ignored, making ALL
155+ * Determines whether the check for "required" properties should be ignored, making all
153156 * mapped values optional, whether or not the isOptional property mapping parameter is set.
154157 * If true, any missing properties when serializing or deserializing will be ignored, as if they
155- * were marked optional. Defaults to false.
158+ * were marked optional.
156159 */
157- private _ignoreRequiredCheck = false ;
160+ private _ignoreRequiredCheck : boolean = false ;
158161
159162 /**
160- * Determines whether the check for "required" properties should be ignored, making ALL
163+ * Determines whether the check for "required" properties should be ignored, making all
161164 * mapped values optional, whether or not the isOptional property mapping parameter is set.
162165 * If true, any missing properties (undefined) when serializing or deserializing will be
163- * ignored, as if they were marked optional. Note that properties explicitly set to null
164- * will be unaffected by this flag - they will be ignored if optional and included if not.
165- * Defaults to false.
166- * @returns {boolean } true if all mapped properties will be considered optional, even if the mapping
167- * doesn't explicitly specify this, false if the mapping will determine whether
168- * a property is optional or not (default)
166+ * ignored, as if they were marked optional.
167+ *
168+ * @see https://www.npmjs.com/package/json2typescript full documentation
169169 */
170170 get ignoreRequiredCheck ( ) : boolean {
171171 return this . _ignoreRequiredCheck ;
172172 }
173173
174174 /**
175- * Determines whether the check for "required" properties should be ignored, making ALL
175+ * Determines whether the check for "required" properties should be ignored, making all
176176 * mapped values optional, whether or not the isOptional property mapping parameter is set.
177177 * If true, any missing properties (undefined) when serializing or deserializing will be
178- * ignored, as if they were marked optional. Note that properties explicitly set to null
179- * will be unaffected by this flag - they will be ignored if optional and included if not.
180- * Defaults to false.
181- * @param value true if all mapped properties will be considered optional, even if the mapping
182- * doesn't explicitly specify this, false if the mapping will determine whether a
183- * property is optional or not (default)
178+ * ignored, as if they were marked optional.
179+ *
180+ * @see https://www.npmjs.com/package/json2typescript full documentation
184181 */
185- set ignoreRequiredCheck ( value : boolean ) {
182+ set ignoreRequiredCheck ( value : boolean ) {
186183 this . _ignoreRequiredCheck = value ;
187184 }
188185
@@ -229,7 +226,6 @@ export class JsonConvert {
229226 *
230227 * @throws an Error in case of failure
231228 *
232- * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
233229 * @see https://www.npmjs.com/package/json2typescript full documentation
234230 */
235231 serialize < T > ( data : any | any [ ] , classReference ?: { new ( ) : T } ) : any | any [ ] {
@@ -245,9 +241,9 @@ export class JsonConvert {
245241 return this . serializeObject ( data , classReference ) ;
246242 } else {
247243 throw new Error (
248- "Fatal error in JsonConvert. " +
249- "Passed parameter data in JsonConvert.serialize() is not in valid format (object or array)." +
250- "\n"
244+ "Fatal error in JsonConvert. " +
245+ "Passed parameter data in JsonConvert.serialize() is not in valid format (object or array)." +
246+ "\n"
251247 ) ;
252248 }
253249 }
@@ -268,7 +264,6 @@ export class JsonConvert {
268264 *
269265 * @throws an Error in case of failure
270266 *
271- * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
272267 * @see https://www.npmjs.com/package/json2typescript full documentation
273268 */
274269 serializeObject < T > ( data : any , classReference ?: { new ( ) : T } ) : any {
@@ -327,8 +322,7 @@ export class JsonConvert {
327322 for ( const propertyKey of Object . keys ( instance as any ) ) {
328323 try {
329324 this . serializeObject_loopProperty ( data , instance , propertyKey , jsonObject ) ;
330- }
331- catch ( ex ) {
325+ } catch ( ex ) {
332326 if ( this . operationMode === OperationMode . LOGGING ) {
333327 console . log ( "Failed to serialize property:" ) ;
334328 console . log ( ex ) ;
@@ -364,7 +358,6 @@ export class JsonConvert {
364358 *
365359 * @throws an Error in case of failure
366360 *
367- * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
368361 * @see https://www.npmjs.com/package/json2typescript full documentation
369362 */
370363 serializeArray < T > ( dataArray : any [ ] , classReference ?: { new ( ) : T } ) : any [ ] {
@@ -414,7 +407,7 @@ export class JsonConvert {
414407 let jsonArray : any [ ] = [ ] ;
415408
416409 // Loop through all array elements
417- for ( const dataObject of < any > dataArray ) {
410+ for ( const dataObject of < any > dataArray ) {
418411 jsonArray . push ( this . serializeObject ( dataObject , classReference ) ) ;
419412 }
420413
@@ -438,7 +431,6 @@ export class JsonConvert {
438431 *
439432 * @throws an Error in case of failure
440433 *
441- * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
442434 * @see https://www.npmjs.com/package/json2typescript full documentation
443435 */
444436 deserialize < T > ( json : any , classReference : { new ( ) : T } ) : T | T [ ] {
@@ -472,7 +464,6 @@ export class JsonConvert {
472464 *
473465 * @throws an Error in case of failure
474466 *
475- * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
476467 * @see https://www.npmjs.com/package/json2typescript full documentation
477468 */
478469 deserializeObject < T > ( jsonObject : any , classReference : { new ( ) : T } ) : T {
@@ -525,8 +516,7 @@ export class JsonConvert {
525516 for ( const propertyKey of Object . keys ( instance as any ) ) {
526517 try {
527518 this . deserializeObject_loopProperty ( instance , propertyKey , jsonObject ) ;
528- }
529- catch ( ex ) {
519+ } catch ( ex ) {
530520 if ( this . operationMode === OperationMode . LOGGING ) {
531521 console . log ( "Failed to deserialize property:" ) ;
532522 console . log ( ex ) ;
@@ -556,7 +546,6 @@ export class JsonConvert {
556546 *
557547 * @throws an Error in case of failure
558548 *
559- * @author Andreas Aeschlimann, DHlab, University of Basel, Switzerland
560549 * @see https://www.npmjs.com/package/json2typescript full documentation
561550 */
562551 deserializeArray < T > ( jsonArray : any [ ] , classReference : { new ( ) : T } ) : T [ ] {
@@ -719,7 +708,8 @@ export class JsonConvert {
719708 let jsonValue : any = undefined ;
720709 try {
721710 jsonValue = this . getObjectValue ( json , jsonPropertyName ) ;
722- } catch { }
711+ } catch {
712+ }
723713
724714
725715 // Check if the json value exists
@@ -1024,7 +1014,7 @@ export class JsonConvert {
10241014 return "any" ;
10251015 } else if ( expectedJsonType === String || expectedJsonType === Boolean || expectedJsonType === Number ) {
10261016 return ( new expectedJsonType ( ) ) . constructor . name . toLowerCase ( ) ;
1027- } else if ( typeof expectedJsonType === ' function' ) {
1017+ } else if ( typeof expectedJsonType === " function" ) {
10281018 return ( new expectedJsonType ( ) ) . constructor . name ;
10291019 } else if ( expectedJsonType === undefined ) {
10301020 return "undefined"
0 commit comments