I want my RESTcontroller to get a JSONObject from a post request but when I send this through Postman:
{
"collection":"StudentDB",
"index":{
"joinDate":"2022-12-12"
}
}
It seems to be working, but the problem is that embedded JSONObjects seem to get cast into a LinkedHashmap and not be JSONObjects, so when I run this code:
@PostMapping
@RequestMapping(value="/query",consumes="application/json")
public ResponseEntity query( @RequestBody JSONObject query) {
System.out.println(query.get("index").getClass());
}
Output is:
class java.util.LinkedHashMap
What could be causing this? Is there another way I could do this?
JSONObjects? Is this a custom class?