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

Add support to empty lists, remove Discriminator tag from json output #56

Closed thisAAY closed 1 year ago

thisAAY commented 1 year ago

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:

{
  "links": {
    "self": "https://root.link.com"
  },
  "data": []
}

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.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication