I use jquery to send a json object servlet
It send the following data in the request
Form Dataview URL encoded stringArray[]:s1
stringArray[]:s2
stringArray[]:s3
objectArray[0][key1]:val1
objectArray[0][att1]:att val1
objectArray[1][key2]:val2
objectArray[1][att2]:att val2
objectArray[2][key3]:val3
objectArray[2][att3]:att val3
for the string array, I can use request.getParameterValues["stringArray"]
but the object array is cannot. How I can get the json array in the servlet?
var json={"stringArray":["s1", "s2", "s3"],
"objectArray":[{"key1":"val1", "att1":"att val1"},
{"key2":"val2", "att2":"att val2"},
{"key3":"val3", "att3":"att val3"}]
};
$.ajax
(
{
url:'../test',
data:json,
type:'post',
cache:false,
dataType:'json',
success:function(data)
{
},
error:function(){alert('error');}
}
);