relationship meta when relationship is a collection
{
"data": {
"type": "people",
"id": "9",
"attributes": {
"first-name": "Dan",
"last-name": "Gebhardt",
"twitter": "dgeb"
},
"links": {
"self": "http://example.com/people/9"
},
"relationships":{
"articles":[
{
"type": "articles",
"id": "1",
"meta":{
"message":"123 testing"
}
},
{
"type": "articles",
"id": "2",
"meta":{
"message":"bad testing"
}
}
]
}
}
}
how do i access message ???
Hey @uddyami ,
Did you try creating a class:
public class ArticleMeta {
private String message;
// getters and setters
}
And than add it as a property to the Article type and annotate it with @Meta
The problem is its not a meta on the object but in that relationship. If same article is in relationship with another person this breaks the idea
Hello @uddyami,
It seams that relationships object that you provided as an example is invalid, it should look like this:
{
"data": {
"type": "people",
"id": "9",
"attributes": {
"first-name": "Dan",
"last-name": "Gebhardt",
"twitter": "dgeb"
},
"links": {
"self": "http://example.com/people/9"
},
"relationships": {
"articles": {
"data": [
{
"type": "articles",
"id": "1",
"meta": {
"message": "Resource meta"
}
},
{
"type": "articles",
"id": "2",
"meta": {
"message": "Resource meta"
}
}
],
"meta": {
"message": "This would be relationship meta"
}
}
}
}
}
Please see this example on the spec: http://jsonapi.org/format/#document-compound-documents
To access relationship meta, define an attribute with RelationshipMeta and set its value to the name of the relationship, in this case articles.
Hey @jasminb To be more specific, what @uddyami meant is that we having problems with deserializing following response:
{
"data": {
"type": "people",
"id": "9",
"attributes": {
"first-name": "Dan",
"last-name": "Gebhardt",
"twitter": "dgeb"
},
"relationships":{
"publishers": {
"data": [
{
"type": "publisher",
"id": "id1"
},
{
"type": "publisher",
"id": "id2"
}
]
}
},
"included": [
{
"type": "articles",
"id": "1",
"attributes": {
"article_name": "Name1"
}
},
{
"type": "articles",
"id": "2",
"attributes": {
"article_name": "Name2"
}
},
{
"type": "articles",
"id": "3",
"attributes": {
"article_name": "Name3"
}
},
{
"type": "articles",
"id": "4",
"attributes": {
"article_name": "Name4"
}
},
{
"type": "publisher",
"id": "id1",
"relationships":{
"articles": {
"data": [
{
"type": "articles",
"id": "1",
"meta": {
"message": "Some message"
}
},
{
"type": "articles",
"id": "2",
"meta": {
"message": "Another message"
}
}
]
}
}
},
{
"type": "publisher",
"id": "id2",
"relationships":{
"articles": {
"data": [
{
"type": "articles",
"id": "3",
"meta": {
"message": "Some message"
}
},
{
"type": "articles",
"id": "4",
"meta": {
"message": "Another message"
}
}
]
}
}
}
]
}
}
So seems like your lib replaces Resource Identifier Object "articles" inside Publisher relationships with full Article model from "included". BUT it ignores and doesn't merges meta block of Resource Identifier Object into Article model. But according to JSON API Specs we can do such thing (http://jsonapi.org/format/#document-resource-identifier-objects) - "A “resource identifier object” MAY also include a meta member, whose value is a meta object that contains non-standard meta-information."
We will be glad to have a fix for that or workaround suggestions (without changing response format). Thanks for your help.
Hey @kowalski89,
Sadly, there is no handling for the meta on the identifier object.
Just few days ago, I've introduced support for custom identifier object, maybe it could be extended to support meta on identifiers also. Let me think about it some more.
If you guys have ideas, please do not hesitate to write them here so we can discuss and move this forward.
Regards