Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with parsing empty Relationship array #89

Open
mkonkel opened this issue Dec 11, 2018 · 1 comment
Open

Problem with parsing empty Relationship array #89

mkonkel opened this issue Dec 11, 2018 · 1 comment

Comments

@mkonkel
Copy link

mkonkel commented Dec 11, 2018

java.lang.RuntimeException: java.lang.Exception: com.squareup.moshi.JsonDataException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $.data[0].relationships

Retrofit call:

    @GET("someApi/someModel")
    fun getSomeModel(): Single<ArrayDocument<SomeModel>>

Model:

@JsonApi(type = "some_model")
public class SomeModel extends Resource {
    @Json(name = "foo")
    public String foo;
    @Json(name = "bar")
    public String bar;
}

Response:

{
	"data": [{
		"type": "some_model",
		"id": 1,
		"attributes": {
			"foo": "text text",
			"bar": "text text"
		},
		"relationships": [],
		"links": []
	}]
}
@dandehavilland
Copy link

I know this is an old one, but just in case anyone else comes across this problem:

relationships should be an object, not an array: https://jsonapi.org/format/#document-resource-object-relationships

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants