infinum/kotlin-jsonapix

Handling empty arrays

oradkovsky opened this issue · 1 comments

Hello! Under spec (https://jsonapi.org/format/#fetching-resources-responses-200), we have this kind of json possible:

{
  "links": {
    "self": "http://example.com/articles"
  },
  "data": []
}

I believe - unless the changes to library happened recently - the following code will fire and fail:

                is JsonArray -> {
                    val first = jsonElement.jsonArray[0]
                    val type = first.jsonObject[JsonApiConstants.Keys.TYPE]
                    type?.jsonPrimitive?.content!!
                }

Please confirm (or not) the issue and may be you have ideas re workaround. Thanks!

Hey @oradkovsky!
Thanks for your feedback!
Im currently looking into this issue as we are preparing for a new release soon.