I am quite new to Spring Boot and REST API. I am trying to build a simple REST API that deals with arbitrary JSON data. I got it working to the point where I can use GET and POST.
What I would want to achieve is to send the same data back with an additional field added. If the data is this(Can be arbitrary).
{
"firstname" : "Dheeraj",
"lastname" : "Dhall"
}
I would want something like this back.
{
"id": "1"
"firstname" : "Dheeraj",
"lastname" : "Dhall"
}
The method that handles PUT request has JsonNode as the parameter and my model is something like this
public class Person {
private Long id;
private Map<String, String> map;
}
So in the method that handles the PUT request I create a map and load data from the JSON Object. So the problem is that my response is something like this
{
"id": "1"
"map":{
"firstname" : "Dheeraj",
"lastname" : "Dhall"
}
}
How do I get it to print without a "map"? what is the best way to handle arbitrary JSON data?