eclipse-ee4j / eclipse-ee4j/jersey

How to apply SelectableEntityFilteringFeature.QUERY_PARAM on a payload containing a list(json)?

Open
#4,284 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

Imagine a json response which contains a list:
`[
{ "id":1, "name":"a"}, { "id":2, "name":"b" } ... { "id": 100, "name":"c"}
]
`
Having that, when i am trying to apply SelectableEntityFIlteringFeature on the endpoint which returns this payload as a response.
Let's say:
**x.x.x.x/rest/test?select=id**

Then the result is the same as the query param select is not being used, meaning that nothing is being filtered.

This will work if i change the response payload to be like
``
{
"results" : [ { "id":1, "name":"a"}, { "id":2, "name":"b" } ... { "id": 100, "name":"c"}}]
}
``

After adding such a property in my Response class, the feature is working properly.
The response will return only the requested field if i am doing the request like this:
**x.x.x.x/rest/test?select=results.id**

So is there any way to use the feature when the response is a List or a Collection?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.