JSON请求发送 [英] json request send

查看:133
本文介绍了JSON请求发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/5150833/android-send-request-using-json-and-get-response-from-java">android使用JSON发送请求并得到Java的响应

Possible Duplicate:
android send request using json and get response from java

在服务器上的图像将负载通过安卓app.for我们使用JSON ImageView的,如何发送请求给服务器

images on server will be load on the imageview through android app.for we are using json,how to send request to server

推荐答案

阅读从Web服务的内容。

HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet();


URI uri = new URI("http://www.am4b&lat... ...");
httpGet.setURI(uri);

HttpResponse httpResponse = httpClient.execute(httpGet);
InputStream jsonfile = httpResponse.getEntity().getContent();
bufferedReader = new BufferedReader(new InputStreamReader(jsonfile));

String ligneLue = bufferedReader.readLine();
    while(ligneLue !=null)
        {
            stringBuffer.append(ligneLue);
            stringBuffer.append("\n");
            ligneLue = bufferedReader.readLine();
        }
    jsontext = stringBuffer.toString();

分析抗衡的JSON

JSONObject response = new JSONObject(jsontext);
        JSONArray hotspots = new JSONArray(response.getString("hotspots"));
        for (i=0; i<hotspots.length(); i++)
        {   JSONObject hotpost = hotspots.getJSONObject(i);
            monPOI = new POIObject(hotpost);
            //Log.d("JSON_Import", "** " + i + monPOI.verbose());
            POIs.add(monPOI);
        }

这篇关于JSON请求发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆