In your JSON data: nsfw
is null.
But in ImageInfo
struct, nsfw
is defined as a boolean
(it can't be null, only true
or false
)
You have 2 possibilities.
- if you have access to JSON data, don't allow
null
fornsfw
. - use a nullable bool:
public bool? nsfw {get; set;}
If you take second option, this will allow you to have true
, false
or null
as a value for nsfw
and you won't have this error anymore.
Both Nullable<bool>
and bool?
are the same syntax.
More info about Nullable Types