Javascript 在处理过程中访问嵌套的JSON数组

Javascript 在处理过程中访问嵌套的JSON数组,javascript,json,twitter,processing,Javascript,Json,Twitter,Processing,我正在使用Processing解析我从Twitter的流式API下载的数据,我有一个关于如何将Javascript中的内容转换为Processing的问题 基本上,我从Twitter上获得的信息大致如下: [ {"created-at": "May 5th, xx:xx", "text": "This is the content of the tweet", "user":{ "name": "John Doe", "friends_count

我正在使用Processing解析我从Twitter的流式API下载的数据,我有一个关于如何将Javascript中的内容转换为Processing的问题

基本上,我从Twitter上获得的信息大致如下:

[
 {"created-at": "May 5th, xx:xx",
  "text": "This is the content of the tweet",
  "user":{
          "name": "John Doe",
          "friends_count": 100,
         }
 }
]
使用我当前的代码:

我可以使用tweets.getStringx;要访问第一层括号中的任何内容,请原谅我的非技术术语,我对这一点还不熟悉,但如何进入用户数组

根据,javascript解决方案的外观如下所示:

[
 {"created-at": "May 5th, xx:xx",
  "text": "This is the content of the tweet",
  "user":{
          "name": "John Doe",
          "friends_count": 100,
         }
 }
]
var author_name=tweets.user[0]。name

但我不确定如何将其转换为处理知道如何解释的代码。我试过这个:

字符串作者\u name=tweets.user[0]。getStringname


但这不起作用。有人有什么建议吗?

我自己想出来的!谁会猜到呢。如果有人遇到类似的问题,我会这样做:

我并没有意识到这一点,但本例中的用户是另一个JSONObject。正如您必须定义JSONObject tweets一样,您还必须定义一个JSONObject用户,该用户来自tweets。你这样做:

JSONObject user = tweets.getJSONObject("user"); 
从那里,您可以通过简单地使用user.getStringx访问user中的任何内容