4

クロスドメインjsonpリクエストを送信しようとすると:

$.getJSON(url + "?callback=?",
    value : 'John',
    record : {
        value : 'a',
        list : [ 1, 2 ]
    });

次に、次のようなJavaサーブレットで取得しようとします:

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);
    }
}

内部サーブレット リクエスト文字列には、パラメータ名があります。

_=1353482336546
value=John
record[value]=a

リクエスト文字列を元の JSON に解析するにはどうすればよいですか?

組み込みの jetty サーバーを使用しており、JSON 文字列で「JSON to Object」jetty パーサーを使用したい

4

1 に答える 1