I am making a call to JAVA API as follows:
var userDetails = {
userId: userId,
first : "1 one",
second : "2 two"
}
$.ajax({
type : 'POST',
url : "http://" + config.domain + config.root + "/myExp/allExperiment",
dataType : "json",
data : userDetails,
success : function(data) {})
});
And trying to get the passed object as follows:
@RequestMapping(value = "/allExperiment", method = RequestMethod.POST)
public JsonMapModel getAllDatasets(@RequestBody String userDetails) {
System.out.println("Data is " + userDetails);
}
I am getting following at the API Data is second=2+two&userId=16&first=1+one
Any idea how can I convert the above response to the JSONObject or any other collection so that I can refer the passed JSON appropriately.