jsonapi-converter
jsonapi-converter copied to clipboard
include string does not work with nested models? "child.grandchild"
Looking at the code for handling the include string:
private SerializationSettings buildSerializationSettings(String includeString) {
SerializationSettings.Builder settingsBuilder = new SerializationSettings.Builder();
if (includeString != null) {
String[] includes = includeString.split(",");
for (String include: includes) {
settingsBuilder.includeRelationship(include);
}
}
SerializationSettings settings = settingsBuilder.build();
return settings;
}
the .
character isn't dealt with -- it's important for for handling join relationships..
Let's say you have a user, organizations, and users_organizations -- for your user, you'd want to include 'users_organizations.organizations'
. But the .
causes neither of the relationships to be rendered.
I'm also looking at using a include
query parameter.
Where is the code you mentioned? I cannot seem to find it... https://github.com/jasminb/jsonapi-converter/search?utf8=%E2%9C%93&q=includeString&type=
@NullVoxPopuli I am not aware of nested relationship support in jsonapi specification.
All libraries i've used (until i started using java libs) have supported nested includes.
From the specification:
The value of the include parameter MUST be a comma-separated (U+002C COMMA, “,”) list of relationship paths. A relationship path is a dot-separated (U+002E FULL-STOP, “.”) list of relationship names.
Does jsonapi-converter support writing a JSONAPIDocument
with defined includes per request / call to write method? I cannot seem to find that.
Any plan to provide this functionality sometime soon? I also need it. and planning to hack a bit your code. I may share with you, if task is not already planned or in progress.
I also need that fix, till then i have changed include string to be free from '.' . Also the solution should solve issue which arises when there is a include for same type object residing at different level in includes. unless we name both such relationship different we cannot serialize it.