I was looking everywhere how to deserialize part of the JSON into an object and the rest into JsonObject.
for example:
{
"id" : "123",
"message" : {"subject" : "test sub" , "body" : "test body"}
}
I want to deserialize this JSON into this class:
public class className {
private String id;
private transient JsonObject message;
// getters and setters
}
The problem is that after the deserialization I get empty object {}inside "message".
Does anyone have any idea about it?
======================================================
EDIT:
A little more info, I am using Spring MVC, the JSON is being sent by POST message into my controller.
The controller function looks like this:
public @ResponseBody String publish(@RequestBody final className input, final HttpServletRequest request,
final HttpServletResponse response) {
//input.message = {}
}
JsonObjecttype from Gson? Please provide a minimal reproducible example.com.google.gson.JsonObject. I am getting the input into my REST controller using POST request with the JSON in the body. the controller looks like this:public String sendMessage(@RequestBody final className input, ...);I am stopping with breakpoint right after the entrance to the function and check my input, the ID is there but message is empty