Skip to content

Instantly share code, notes, and snippets.

@shikajiro
Created September 26, 2013 12:07
Show Gist options
  • Save shikajiro/6713249 to your computer and use it in GitHub Desktop.
Save shikajiro/6713249 to your computer and use it in GitHub Desktop.
try {
//②feedjsonを読み込む
InputStream in = getAssets().open("feed.json");
BufferedReader buff =
new BufferedReader(new InputStreamReader(in));
StringBuilder bld = new StringBuilder();
String line = null;
while((line = buff.readLine()) != null){
bld.append(line);
}
Log.i("読み込んだjson文字列", bld.toString());
//③文字列をjsonとして扱う
JSONObject json = new JSONObject(bld.toString());
JSONObject responseData = json.getJSONObject("responseData");
JSONObject feed = responseData.getJSONObject("feed");
JSONArray entries = feed.getJSONArray("entries");
for(int i=0; i<entries.length(); i++){
JSONObject entry = entries.getJSONObject(i);
String title = entry.getString("title");
Log.i("title", title);
}
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment