Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Jackson Deserializer for dynamic Fields

$
0
0

We have in our application multiple GET APIs with quite complex filters. All of them contain list of such AttributeFilter objects:

attributes: {  key: string;  exclude: boolean;  values: string[];}[];

in our UI we have also added the filters to the URL and we would like to keep the same design for the REST APIs. They keys can be dynamic, therefore we use a prefix ("attribute.") to identify them. We also use an array excludedAttributes to know what attribute keys have the exclude flag set. E.g.:

/api/v1/some-resources?filter.category=CatA&filter.category=CatB&filter.region=West&excludedAttributes=region

would be mapped to this:

[  {    key: "category",    exclude: false,    values: [ "CatA", "CatB" ]  },  {    key: "region",    exclude: true,    values: [ "West" ]  }]

We are now struggeling with the Deserialization in our Spring Boot app. We would like the controller GET methods to work as easy as the POST methods, where we just have the complete payload as method parameter annotated with @RequestBody, but instead of the request body it should be parsed from the URL params.

Further, this attribute filter is used multiple times in reqeust objects, like this:

RequestOne: {  from: LocalDate;  to: LocalDate;  attributes: AttributeFilter[];}RequestTwo: {  levels: string[];  active: boolean;  attributes: AttributeFilter[];}...

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>