android okgo post傳數組

 JSONObject  json1 = new JSONObject();
        json1.put("memo", fankuiEt.getText().toString());
        json1.put("userid",(int)sp.getSharedPreference(Constant.USERID,0));

 // 1個數組參數
    JSONArray jsonArray = new JSONArray();
    for (String tag : tags) {
        jsonArray.put(tag);
    }
    json1.put("tags", jsonArray);

        Log.d("RegisterActivity", "json1: " + json1);
        MediaType JSON = MediaType.parse("application/json; charset=utf-8");
        RequestBody body = RequestBody.create(JSON, String.valueOf(json1));
        OkGo.<String>post(Urls.urlFankui)
                .upRequestBody(body)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                     
                    }

                    @Override
                    public void onError(Response<String> response) {
                        super.onError(response);
                     
                    }
                });
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章