Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fails to deserialize hasMany relationship when empty #80

@Bartheleway

Description

@Bartheleway

Hi, first thanks for your work.

I'm having some trouble with a hasMany relationship which actually has no records.

I have a JSON like that :

{
  "data": [
    {
      "type": "articles",
      "id": "1",
      "attributes": {
        "title": "My Title",
      },
      "relationships": {
        "comments": {
          "data": null
        }
      }
    }
  ],
}

My model is like that

@JsonApi(type = "article")
public class Article extends UpdatableResource {
  public String title;
  public HasMany<Comment> comments;
}

I'm getting this error :
com.squareup.moshi.JsonDataException: Expected BEGIN_ARRAY but was NULL at path $.data[0].relationships.comments.data

I'm using this converter for retrofit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions