Created
September 26, 2013 12:07
-
-
Save shikajiro/6713249 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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