小编thu*_*rmi的帖子

使用JSON Body,Android执行HTTPPost请求

我对Android很新.所以,我正在使用Json Data在Android中遇到HttpPost.

JSONObject jsonObj = new JSONObject();
JSONObject jsonObjDasUser = new JSONObject();

    jsonObj.put("name", "Login");
    jsonObj.put("type", "request");
    jsonObj.put("UserCredential", jsonObjUserCredential );
    jsonObjUserCredential .put("username", id);
    jsonObjUserCredential .put("password", password);

// Create the POST object and add the parameters
HttpPost httpPost = new HttpPost(url); 

StringEntity entity = new StringEntity(jsonObj.toString(), HTTP.UTF_8);

entity.setContentType("application/json");
httpPost.setEntity(entity);
HttpClient client = new DefaultHttpClient();
Run Code Online (Sandbox Code Playgroud)

如何将jsonObjUserCredential包含为:::

//StringEntity userCredential = new StringEntity(jsonObjUserCredential .toString(),HTTP.UTF_8);??????
Run Code Online (Sandbox Code Playgroud)

这里做错了什么?????

请帮我....

post android json http-post getjson

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

getjson ×1

http-post ×1

json ×1

post ×1