不确定我的头衔是否适合我的问题,但这是我能想到的最好的。
这是我在网站上的JSONString:
{"0":{"productname":"Varios - NEUTROGENA PROTECTOR LABIAL SPF5","imageurl":"http://ecx.images-amazon.com/images/I/41cm5BHMGtL._SL160_.jpg","producturl":"","price":"1.72","currency":"GBP","saleprice":"","storename":"N/A"}}
我想使用提供的类here创建一个JSONObject。
这是我到目前为止所做的:
JSONParser jsonparser = new JSONParser();
String jsonString = null;
JSONObject jsonObject = jsonparser.makeHttpRequest(url, GET, params);
makeHttpRequest 方法接受3个参数:
List<NameValuePair>
我不知道应该在列表中添加什么才能使我的方法有效。我必须以哪种格式将其放在List中,以使该方法返回一个适合以后(易于)使用的propper JSONObject。
答案 0 :(得分:0)
根据linked post中的问题,它来自this tutorial,根据该教程,该列表用于在必要时将params列表传递给使用{{{httprequest的httprequest 1}}类。 org.apache.http.message.BasicNameValuePair
本身是一个界面,其文档在this link
您可以在params列表中添加值,如下所示。摘自教程:
NameValuePair
因此,您只需通过更改添加到列表中的键值对,将所需的参数传递给URL。
希望这有帮助。