infinum / kotlin-jsonapix

JsonApiX is an Android, annotation processor library that was made to transform regular Kotlin classes into their JSON API representations, with the ability to serialize or deserialize them to or from strings.
Apache License 2.0
38 stars 9 forks source link

Nullable primary data #45

Closed Javernaut closed 1 year ago

Javernaut commented 2 years ago

Hello.

Started using this library and faced an issue.

According to the jsonapi standard:

Primary data MUST be either:

a single resource object, a single resource identifier object, or null, for requests that target single resources

And here I want to emphasize 'null'. Exactly for the 'Primary data'. Now if the library receives

{
   "data": null
}

the parsing will crash with the error:

Input must be either JSON object or array with the key type defined.

So the library doesn't handle the case when the primary data is expected to be nullable. Could you please add the support for such a case?

stjepanbanek commented 2 years ago

Hi @Javernaut and thanks for your report. You are right and we will look into this as soon as possible. You can expect this being fixed in the stable release.