当我尝试发送跨域 jsonp 请求时:
$.getJSON(url + "?callback=?",
value : 'John',
record : {
value : 'a',
list : [ 1, 2 ]
});
然后我尝试使用 java servlet 来获取它,如下所示:
public class TestServlet extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String output = request.getParameter("callback")
+ "({\"response\":\"test\"});";
response.setContentType("application/javascript;charset=utf-8");
PrintWriter out = response.getWriter();
out.println(output);
}
}
内部 servlet 请求字符串具有参数名称:
_=1353482336546
value=John
record[value]=a
如何将请求字符串解析为原始 JSON?
我使用嵌入式码头服务器,我想在 JSON 字符串上使用“JSON to Object”码头解析器