Hi guys,
I am using JSON.parse() in java script to parse the json stream returned by the Rest api.
Here is the code that i have written:
var tweets = JSON.parse(httpResponse.text);
var Tweet = Parse.Object.extend(“TweetDB”);
var count = tweets.length;
if(count > 0)
{
for(var i = 0; i< count; i = i +1)
{
var tweet = new Tweet();
tweet.set(“text”, tweets[i].text);
tweet.set(“id_str”, tweets[i].id_str);
tweet.set(“created_at”, tweets[i].created_at);
tweet.set(“urls”, tweets[i].entities.urls[0].url);
.
.
.
Now for the first tweet, i am able to extract the url successfully. But from the second tweet, i am unable to extract the url from the tweet and it throws an error.
Also, each tweet in the JSON stream had a URL and if I comment the code where i extract the url, it works fine.
Can somebody please throw some light on it.
Thanks in advance.
Warm Regards,
Puneet