I'm sending from my client side an ajax request to my server.
this is the data structure that i'm passing:
data = {"key1" : "value1" , "key2" : {"subkey1": "subvalue1" ,"subkey2" : "subvalue2"}};
on the server side i'm doing the following:
private Map<String, Object> parseItemData(HttpServletRequest request) {
Enumeration<String> parameterNames = request.getParameterNames();
while (parameterNames.hasMoreElements()) {
String paramName = parameterNames.nextElement();
String[] paramValues = request.getParameterValues(paramName);
if(paramName.equals("itemSpecifics"))
{
System.out.println(paramName);
for (int i =0 ; i<paramValues.length; i++)
{
System.out.println(paramName +": "+paramValues[i] );
}
}
}
return item;
}
this is the output that i'm getting:
itemSpecifics: [object Object]
is there any way to do it?
Solution :
in case of nested key value pair, i had to manual use JSON.stringify()
for the nested key value in order to send it as JSON
.