Ich habe diese Antwort JSON, die theoretisch die JSON API-Spezifikationen folgt. Ich versuche, mit der moshi-jsonapi library zu analysieren, aber ich weiß nicht, wie man die some_objects
Beziehung analysiert. In der SomeType
Klasse habe ich ein Mitglied HasMany<SomeObject> someObjects
und die Klasse SomeObject
in geeigneter Weise mit Anmerkungen versehen sind:JSON API Beziehungen mit Moshi
@JsonApi(type = "some_objects")
public class SomeObject extends Resource {
//....
}
Aber nach der Analyse zu tun, erhalte ich das someObjects
Mitglied als null. Wer weiß warum?
Die JSON ist, dass man:
"links": {
"self": "someurl/params"
},
"data": [
{
"type": "some_type",
"id": "12345",
"attributes": {
"attr1": 1,
"attr2": 2,
"attr3": 3
},
"relationships": {
"some_objects": {
"data": [
{
"type": "some_objects",
"id": "1"
},
{
"type": "some_objects",
"id": "2"
}
]
}
}
}
],
"included": [
{
"type": "some_objects",
"id": "1",
"attributes": {
"id": "1",
"parentId": "1"
},
"relationships": {
"subobjects": {
"data": [
{
"type": "subobjects",
"id": "2"
}
]
}
}
{
"type": "subobjects",
"id": "2",
"attributes": {
"metadata": {
"code": "AA"
},
"id": "2",
"parentId": "1"
}
}
],
"meta": {
"total": 1,
"totalCount": 1,
"correction": []
}
}