views:

99

answers:

1

Hi, I'm currently looking into the Twitter-API - specifically the daily trends-API (http://search.twitter.com/trends/current.json).

Example return from Twitter

{
      trends: {
            2009-11-19 14:29:16: [
                  { 
                      name: "#nottosayonfirstdate",
                      query: "#nottosayonfirstdate"
                  },
                  {
                      name: "New Moon",
                      query: ""New Moon""
                  },
                  {
                      name: "#justbecause",
                      query: "#justbecause"
                  }
            ]
        }
}

I wonder how I can return the values within there without knowing the exact date at the time of the call, since it won't be possible to synchronise the client-time with the server-time.

Normally, I'd go for trends.something[1].name to get the name, but since the timestamp will change all the time, how can I get it when trends is no array?

+3  A: 

you can use this:

for (var i in trends) {
    alert (i);                 // "2009-11-19 14:29:16"
    alert (trends[i][0].name); // "#nottosayonfirstdate"
}
nickf