LHS Brackets style of query parameters is commonly used, it used by Stripe, GoCardless, and others.
Sample: htps://domain.com?price[gte]=200&price[lte]=500
https://www.moesif.com/blog/technical/api-design/REST-API-Design-Filtering-Sorting-and-Pagination/#lhs-brackets
Will be great to be possible to map this to the class
class Price {
private Long gte;
private Long lte;
// ...
}
class Request {
private Price price;
// ...
}
It works if the price
is a Map
class Request {
private Map<String, String> price;
// ...
}
But it doesn't work for a class
.
Comment From: spencergibb
Should probably be a spring framework issue since that is where spring mvc and webflux live.
Comment From: wilkinsona
Yep. We'll move it over.
Comment From: rstoyanchev
Data binding uses JavaBean conventions and that's the syntax for maps, see: https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-beans-conventions
The following works:
public class Request {
private Map<String, Long> price;
public Map<String, Long> getPrice() {
return price;
}
public void setPrice(Map<String, Long> price) {
this.price = price;
}
}
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: eric-gymondo
Hey Guys, I think this feat would be a nice addition to spring in general, qs does something really cool with being able to parse brackets to objects and objects to brackets https://github.com/ljharb/qs.
I see that the issue was closed, does it mean the spring team did not see a value on it?
Comment From: Jotschi
I started work on a LHS filter parser for my own project. Found this issue while searching for an existing solution. Maybe someone finds this useful. https://github.com/metaloom/lhs-filter