如何使用 Android 通过 Request 发送 JSON 对象(在 get 方法中)?

How to send a JSON object(in get method) over Request with Android?

我要发送以下参数

 data={"method": "category", "parameter": {"id":20, "language":"en"}} 

到网络服务 我怎样才能从 android 获取方法? 我试过了,但没有用。

您的 JSON 是这样创建的:

 try {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("method", "category");
                JSONObject jsonObject1 = new JSONObject();
                jsonObject1.put("id", 20);
                jsonObject1.put("language", "en");
                jsonObject.put("parameter",jsonObject1 );
            } catch (JSONException e) {
                e.printStackTrace();
            }

现在您可以将其添加到您的请求中,密钥为 "data"

试试这个

JSONObject jsonObject = new JSONObject();
jsonObject.put("id",20 );
jsonObject.put("language","en");

JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("method", "category");
jsonObject2.put("parameter", jsonObject.toString());