Skip to content

Commit ac9bbe9

Browse files
Fixed wrong comments, updated documentation
1 parent b5c6ca2 commit ac9bbe9

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# v1.2.0 (2019-02-21)
2+
3+
## Features
4+
5+
* Allow optional properties to be null, closes [#58](https://github.com/dhlab-basel/json2typescript/issues/58)
6+
7+
## Breaking Changes
8+
9+
* If a property is declared optional (by `@JsonProperty(name, Type, true)`), then `null` is now ignored in both serialization and deserialization.
10+
Before this version, `json2typescript` would have thrown an error if `ValueChecking.DISABLE_NULL` was used.
11+
112
# v1.1.1 (2019-02-12)
213

314
## Features

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ Make sure you catch the errors in production!
3232

3333
See the changelog in the seperate file for bug fixes, new features and breaking changes: [Changelog](CHANGELOG.md)
3434

35-
> Tip: At version 1.1.0 we introduced some soft breaking changes.
35+
> Tip: At version 1.2.0 we introduced one more soft breaking change.
36+
`null` values will now be ignored when you serialize or deserialize optional values.
37+
This means that you are now able to use `ValueCheckingMode.DISALLOW_NULL` even when your API returns null values in the JSON.
38+
In that case, you should mark them optional.
39+
40+
> Tip: At version 1.1.0 we introduced some soft breaking change.
3641
`undefined` is an invalid value now for serializing or deserializing.
3742
If you are working with TypeScript, you might receive some type issues after the update to v1.1.0.
3843
This is due to the addition of generics; they now help the compiler to detect invalid return types in the serialize and deserialize methods.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json2typescript",
3-
"version": "1.1.1",
3+
"version": "1.2.0",
44
"description": "Provides TypeScript methods to map a JSON object to a JavaScript object on runtime",
55
"keywords": [
66
"convert",

src/json2typescript/json-convert-decorators.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Any } from "./any";
66
*
77
* @param target the class
88
*/
9-
export function JsonConverter(target: any) {
9+
export function JsonConverter(target: any): void {
1010
target[Settings.MAPPER_PROPERTY] = "";
1111
}
1212

@@ -15,7 +15,7 @@ export function JsonConverter(target: any) {
1515
*
1616
* @param target the class identifier or the class
1717
*
18-
* @returns {any}
18+
* @returns
1919
*
2020
* @throws Error
2121
*/
@@ -94,11 +94,11 @@ export function JsonObject(target?: string | any): any {
9494
* @param conversionOption optional param (default: Any), should be either the expected type (String|Boolean|Number|etc) or a custom converter class implementing JsonCustomConvert
9595
* @param isOptional optional param (default: false), if true, the json property does not have to be present in the object
9696
*
97-
* @returns {(target:any, classPropertyName:string)=>void}
97+
* @returns
9898
*
9999
* @throws Error
100100
*/
101-
export function JsonProperty(...params: any[]): any {
101+
export function JsonProperty(...params: any[]): { (target: any, classPropertyName: string): void } {
102102

103103
return function (target: any, classPropertyName: string): void {
104104
// target is the class

0 commit comments

Comments
 (0)