Is there a "spring way" to parse deepObjects given in url as parameters? Let's say I have a "Filter" object with JSON representation:
{
"id": 5,
"name": "Andrew"
}
Documentation of project says, that this is "deepObject", so when I receive url with this object as a parameter, i should expect:
hostname/api/person?filter[id]=5&filter[name]=Andrew
My problem is that I cannot parse this parameter into object using, known to me, spring ways. After creation Object "Field" with the same fields as JSON.
I tried using annotation @RequestParam
@RequestMapping(value = "api/person", method = RequestMethod.GET)
public ResponseEntity<List<Person>> getPerson(
@RequestParam Filter filter
) {
//method body..
}
and also not using this annotation - as it suppose to be, according to documentation...
@RequestMapping(value = "api/person", method = RequestMethod.GET)
public ResponseEntity<List<Person>> getPerson(
Filter filter
) {
//method body..
}
In both ways i ended up with having "null" as a result. Even, when trying to parse this parameters to generic "Object", null is only thing that comes out of it.
Now i am using MultiValueMap<String, String> allParams, as one of @RequestParam, and parse parameters manually to desired form, but it is not seems to be the best solution.
Is there a better (correct) way to do that? I am using Java 1.6 and spring 4.0.9 (limited by jdk).
Thank you in advance!
@Edit According to comments, it looks like there is no spring mechanism to do that.