I am currently working with a REST web service. one of the methods is a POST request, in which the user sends some configuration details in the format of JSON. The number of configuration parameters and the parameters themselves will vary. Basically, it would look something like :
{
"configParam1" : "value1",
"configParam2" : "value2",
"configParam3" : "value3"
}
or it could look like this:
{
"configParam1 ": "value1",
"configParam2" : "value2"
}
meaning that the number of keys and the actual keys themselves would vary. I need to convert this JSON to a map.
I know that you can do so by creating a POJO and it will be converted according to the class, however, given that the parameters vary, I can't have a hard class definition to convert to.
Is there any way to go around this?
Generally, Instead of putting something like :
@POST
@Produces(MediaType.APPLICATIONJSON)
@Consumes(MediaType.APPLICATIONJSON)
methodName(MyClassObject postJSONresponse){
}
can I just do:
@POST
@Produces(MediaType.APPLICATIONJSON) .
@Consumes(MediaType.APPLICATIONJSON) .
methodName(Map (string,string) postJSONrepsonse){
} ?
Is there a better way to do this?
Please Help if you can.