这是我将 json 对象发送到 servlet 的 javascript 代码
username = "Nash";
password = "619here";
type = "all";
data = '{ "username": "' + username + '", "password": "' + password + '", "type": "' + type + '" }';
request = JSON.parse(data);
$.getJSON(url, request, function (response) {
$("#result").append("<h1>Success</h1>");
$.each(response.vehicle, function (no, vehicle) {
$.each(vehicle, function (key, value) {
$("#result").append("<h2>" + key + " : " + value + "</h2>");
});
$("#result").append("<br>");
});
})
我想从 java servlet 读取 json 对象并分别获取数据。像这样
String username = username from json object
String password = password from json object
String type = type from json object
我正在使用 json-lib-2.4-jdk15.jar 请帮帮我..