使用Android通过解析给定JSON数组的JSON来显示推文

时间:2022-10-29 20:39:08

Following the tutorial blog post on http://www.heath-bar.com/blog/?p=599, I was able to get the JSON array for a user's timeline in my Android application. I understand tweets have a key of "text" but the data I have is nested and there are multiple tweets.

按照http://www.heath-bar.com/blog/?p=599上的教程博客文章,我能够在我的Android应用程序中获取用户时间轴的JSON数组。我知道推文有一个“文本”键,但我拥有的数据是嵌套的,有多条推文。

What is the most reasonable way to parse through the JSON array (currently a String) to get all the tweet text only?

解析JSON数组(当前是String)以获取所有推文文本的最合理方法是什么?

1 个解决方案

#1


0  

ArrayList<String> tweetlist = new ArrayList<String>();
for(int i =0;i<i<yourjsonarray.lengh();i++)
{
String tweet =yourjsonarray.getjsonobject(i).getstring("text");
tweetlist.add(tweet);
}

#1


0  

ArrayList<String> tweetlist = new ArrayList<String>();
for(int i =0;i<i<yourjsonarray.lengh();i++)
{
String tweet =yourjsonarray.getjsonobject(i).getstring("text");
tweetlist.add(tweet);
}