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
Add support to empty lists, remove Discriminator tag from json output #56
An error is generated. Previously, if the list was empty, the type was inferred using the Model type, such as XItem. This approach is incorrect. Instead, we should directly use the Data type. For instance, in the case of the Person example, we should utilize the Person class rather than PersonList.
I've incorporated additional tests to address scenarios involving Meta and links. I'll continue to add tests as I identify new edge cases. At present, our tests focus on decoding and encoding. I plan to extend testing to include the generation process in the future.
Here's a revised version of the GitHub Pull Request description:
When attempting to decode a List from an empty JSON list as shown below:
An error is generated. Previously, if the list was empty, the type was inferred using the
Model
type, such asXItem
. This approach is incorrect. Instead, we should directly use theData
type. For instance, in the case of thePerson
example, we should utilize thePerson
class rather thanPersonList
.I've incorporated additional tests to address scenarios involving Meta and links. I'll continue to add tests as I identify new edge cases. At present, our tests focus on decoding and encoding. I plan to extend testing to include the generation process in the future.