Closed pmurph0 closed 2 years ago
This is a valid JSON API spec payload, with an attribute and relationship both called payments
payments
{ "id": "ID_HERE", "type": "checks", "attributes": { "payments": [ { "id": "ID_HERE", "check_id": "ID_HERE", } ] }, "relationships": { "payments": { "data": [ { "type": "payments", "id": "ID_HERE" } ] }
But I can't deserialize it to my model which looks like this:
@JsonApi(type = "checks") data class Check( @Json(name = "payments") val paymentsResource: HasMany? = null, @Json(name = "payments") val payments: List? = emptyList() )
As the deserializer complains of a clash when mapping because of having 2 fields with the same Json name:
com.squareup.moshi.JsonDataException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at path $.data[0].relationships.payments
Is there a way to handle this?
I'm sorry but actually that's not a valid JSONAPI resource according to the spec:
a resource can not have an attribute and relationship with the same name
Maybe we can have some test case for this :smile:
This is a valid JSON API spec payload, with an attribute and relationship both called
payments
But I can't deserialize it to my model which looks like this:
As the deserializer complains of a clash when mapping because of having 2 fields with the same Json name:
Is there a way to handle this?