-
Notifications
You must be signed in to change notification settings - Fork 26
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
Empty array if no embedded representation is added #39
Comments
Correct me if I'm wrong - but you're using two separate rels: You're first example - |
And yes - you can't embed a non object node - that error should be more gracefully handled, probably at the time of constructing the {
"0": ....,
"1": ....
} |
Hi Mark, you're right. The expected output is wrong. I'll need to correct the description. We're using a HAL client in the frontend to follow the relations provided by the HAL payload: What we're trying to achieve in the above example is provide a list of
and we get:
The HAL client follows the relation But if the list of items is empty, we get:
which for the HAL client means Now back to the expected output. You're right. The expected output in the above description isn't correct. The expected output would contain an empty
I've not corrected the initial description. I guess this comment shows the intention much better than the initial description. It might be better to close this issue and create a new one with this comment as the description? Regards, |
Hi,
This issue applies to v5.1.1, 5.1.2-SNAPSHOT (and the current "develop" branch).
There seems to be no way to add an empty array as an
_embedded
object, e.g. withI get the following output:
Since I used
.withRel( Rels.collection( "item" ) )
I expected the output to include an empty array:The code
results in
"item": [ { } ]
which is not correct.The code
results in an Exception:
The code
actually provides the expected result although it seems to be more of a work around to set the
value
of theResourceRepresentation
to an object{ "list": [ ] }
. The bad thing of this work around is that we will need a check for an empty list beforehand and if it's empty, we create this representation, else we create the "normal" representation. It might be a good idea to make the initial example with.withRel( Rels.collection( "item" ) )
lead to the same result.Regards,
Markus
The text was updated successfully, but these errors were encountered: