代码如下:
String json = "{\"action_name\":\"QR_LIMIT_SCENE\",\"action_info\":{\"scene\":{\"scene_id\":234}}}";
HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
StringEntity postingString = new StringEntity(json);// json传递
post.setEntity(postingString);
post.setHeader("Content-type", "application/json");
HttpResponse response = httpClient.execute(post);
String content = EntityUtils.toString(response.getEntity());
// Log.i("test",content);
System.out.println(content);
result = content;
也可以用Json对象
Map<String, String> map = new HashMap<String, String>();
map.put("filemodule", "GAP");
map.put("userid", "18914786345");
map.put("orderno", "775329");
map.put("custid", "NJYESZ");
String jsonPost = returnData.toString();
StringEntity postingString = new StringEntity(jsonPost);