-1

JSON API を使用する必要がありますが、その方法がわかりません。私が見つけたすべてのチュートリアルは、ファイルからの json の解析に関するものです。

次のようなリクエストを行う必要があります: http://expandurl.appspot.com/expand?url=http%3A%2F%2Ft.co%2FgLP0Ucg

そして、これを返します

{"status": "OK", "end_url": "http://www.systemcomic.com/2011/06/27/the-system-506-office-forecast/", "redirects": 3, "urls": ["http://t.co/gLP0Ucg", "http://www.notquitewrong.com/rosscottinc/2011/06/27/the-system-506-office-forecast/", "http://www.systemcomic.com//2011/06/27/the-system-506-office-forecast/", "http://www.systemcomic.com/2011/06/27/the-system-506-office-forecast/"], "start_url": "http://t.co/gLP0Ucg"}

end_url 文字列だけが必要です。どうすればいいですか?また、これを ASyncTask で行う予定です

4

1 に答える 1

1

を取得するには、JSONhttp リクエストを使用して抽出する必要があり、応答を取得したら、それを解析してend_url.

これを解析してみてくださいend_url

final Pattern pattern = Pattern.compile("\"end_url\": \"(.+?)\",");
final Matcher matcher = pattern.matcher(You_json_string);
matcher.find();
Log.d("end_url" , matcher.group(1));
于 2014-06-14T14:54:24.063 に答える