Closed waritsan closed 8 years ago
Umm... I think you've forgotten to add a @Json
annotation to the articles
field.
@JsonApi(type = "authors")
public class Author extends Resource {
@Json(name = "name") String name;
@Json(name = "sports-articles")
HasMany<Article> articles;
}
Note that the "key" in relationships object indicates a field name, and have no relationship with the type of the linked object, which is determined by type
of a resource linkage object.
Oh I see. Thank you for the clarification.
Hi, I get a java.lang.NullPointerException when I try to get the relationship resource with included: [] in the JSON body. This seems to only occur when the relationship resource type has a dash, for example when the type is "sports-articles" I get an error. But if I change the type both in the JSON body and JsonApi annotation to "articles", it works fine. I'm not sure why this is happening. Please advise. Here's an example of my code.