json2typescript
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -0,1 +1,7 @@ | ||
# v1.2.3 (2019-05-11) | ||
## Bug Fixes | ||
* Wrong output files were included in v1.2.x builds, closes [#98](https://github.com/dhlab-basel/json2typescript/issues/98) | ||
# v1.2.2 (2019-05-04) | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "json2typescript", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Provides TypeScript methods to map a JSON object to a JavaScript object on runtime", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -12,3 +12,3 @@ /** | ||
* | ||
* @returns {any} | ||
* @returns | ||
* | ||
@@ -34,6 +34,8 @@ * @throws Error | ||
* | ||
* @returns {(target:any, classPropertyName:string)=>void} | ||
* @returns | ||
* | ||
* @throws Error | ||
*/ | ||
export declare function JsonProperty(...params: any[]): any; | ||
export declare function JsonProperty(...params: any[]): { | ||
(target: any, classPropertyName: string): void; | ||
}; |
@@ -19,3 +19,3 @@ "use strict"; | ||
* | ||
* @returns {any} | ||
* @returns | ||
* | ||
@@ -81,3 +81,3 @@ * @throws Error | ||
* | ||
* @returns {(target:any, classPropertyName:string)=>void} | ||
* @returns | ||
* | ||
@@ -84,0 +84,0 @@ * @throws Error |
@@ -494,3 +494,3 @@ "use strict"; | ||
var classInstancePropertyValue = instance[classPropertyName]; | ||
// Check if the json value exists | ||
// Check if the class property value exists | ||
if (typeof (classInstancePropertyValue) === "undefined") { | ||
@@ -504,5 +504,8 @@ if (isOptional) | ||
} | ||
// Check if the property is optional | ||
// If the json value is null, we don't assign it in that case | ||
if (isOptional && classInstancePropertyValue === null) | ||
return; | ||
// Map the property | ||
try { | ||
// Each class property might have multiple decorators - only use the JSON property name as defined in the first one | ||
json[jsonPropertyName] = customConverter !== null ? customConverter.serialize(classInstancePropertyValue) : this.verifyProperty(expectedJsonType, classInstancePropertyValue, true); | ||
@@ -554,2 +557,6 @@ } | ||
} | ||
// Check if the property is optional | ||
// If the json value is null, we don't assign it in that case | ||
if (isOptional && jsonValue === null) | ||
return; | ||
// Map the property | ||
@@ -556,0 +563,0 @@ try { |
Sorry, the diff of this file is not supported yet
121615
1539