You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that if we set ignorePrimitiveChecks = true, then all undefined properties are ignored as well.
Example:
JSON:
{ "testt": "Hello World" }
TYPESCRIPT:
class Test {
@JsonProperty("test", "String") test: string = "";
}
Deserializing the JSON above usually results in an error (property test not found in the JSON). However, when ignorePrimitiveChecks = true, then the error is ignored.
The reason is the following: json2typescript considers a missing property undefined. undefined is a primitive property and we ignore the type. Instead, json2typescript maps the undefined value to the test property in the class.
Is this behavior to be expected? Or should we treat a missing property different?
Note again, that in case ignorePrimitiveChecks = false, which is the default, there is an exception because undefined cannot be mapped as a String.
I noticed that if we set
ignorePrimitiveChecks = true
, then allundefined
properties are ignored as well.Example:
JSON:
TYPESCRIPT:
Deserializing the JSON above usually results in an error (property test not found in the JSON). However, when
ignorePrimitiveChecks = true
, then the error is ignored.The reason is the following: json2typescript considers a missing property
undefined
.undefined
is a primitive property and we ignore the type. Instead, json2typescript maps the undefined value to thetest
property in the class.Is this behavior to be expected? Or should we treat a missing property different?
Note again, that in case
ignorePrimitiveChecks = false
, which is the default, there is an exception becauseundefined
cannot be mapped as aString
.CC: @tobiasschweizer @antal-horvath
The text was updated successfully, but these errors were encountered: