[R] Reading Json data

Mayukh Dass mayukh.dass at gmail.com
Mon Jul 27 22:41:17 CEST 2015


Hello,

I am trying to read a set of json files containing tweets using the
following code:

json_data <- fromJSON(paste(readLines(json_file))

Unfortunately, it only reads the first record on the file. For example, in
the file below, it only reads the first record starting with "id":"tag:
search.twitter.com,2005:3318539389". What is the best way to retrieve these
records? I have 20 such json files with varying number of tweets in it.
Thank you in advance.

Best,
Mayukh

{"id":"tag:search.twitter.com
,2005:3318539389","objectType":"activity","actor":{"objectType":"person","id":"id:
twitter.com:2859421","link":"http://www.twitter.com/meetjenn","displayName":"Jenn","postedTime":"2007-01-29T17:06:00.000Z","image":"06-19-07_2010.jpg","summary":"I
say 'like' a lot. I fall down a lot. I walk into everything. Love Pgh Pens,
NE Pats, Fundraising, Dogs & History. Craft Beer & Running
Novice.","links":[{"href":"http://meetjenn.tumblr.com","rel":"me"}],"friendsCount":0,"followersCount":0,"listedCount":0,"statusesCount":0,"twitterTimeZone":"Eastern
Time (US &
Canada)","verified":false,"utcOffset":"0","preferredUsername":"meetjenn","languages":["en"],"location":{"objectType":"place","displayName":"Pgh/Philajersey"},"favoritesCount":0},"verb":"post","postedTime":"2009-08-15T00:00:12.000Z","generator":{"displayName":"tweetdeck","link":"
http://twitter.com
"},"provider":{"objectType":"service","displayName":"Twitter","link":"
http://www.twitter.com"},"link":"
http://twitter.com/meetjenn/statuses/3318539389","body":"Cool story about
the man who created the @Starbucks logo. Additional link at the bottom on
how it came to be:  http://bit.ly/16bOJk
","object":{"objectType":"note","id":"object:search.twitter.com,2005:3318539389","summary":"Cool
story about the man who created the @Starbucks logo. Additional link at the
bottom on how it came to be:  http://bit.ly/16bOJk","link":"
http://twitter.com/meetjenn/statuses/3318539389
","postedTime":"2009-08-15T00:00:12.000Z"},"twitter_entities":{"urls":[{"expanded_url":null,"indices":[111,131],"url":"
http://bit.ly/16bOJk
"}],"hashtags":[],"user_mentions":[{"id":null,"name":null,"indices":[41,51],"screen_name":"@Starbucks","id_str":null}]},"retweetCount":0,"gnip":{"matching_rules":[{"value":"Starbucks","tag":null}]}}
{"id":"tag:search.twitter.com
,2005:3318543260","objectType":"activity","actor":{"objectType":"person","id":"id:
twitter.com:61595468","link":"http://www.twitter.com/FastestFood","displayName":"FastFood
Bob","postedTime":"2009-01-30T20:51:10.000Z","image":"","summary":"Just A
little food for
thought","links":[{"href":"http://www.TeamSantilli.com","rel":"me"}],"friendsCount":0,"followersCount":0,"listedCount":0,"statusesCount":0,"twitterTimeZone":"Pacific
Time (US &
Canada)","verified":false,"utcOffset":"0","preferredUsername":"FastestFood","languages":["en"],"location":{"objectType":"place","displayName":"eating
some
thoughts"},"favoritesCount":0},"verb":"post","postedTime":"2009-08-15T00:00:23.000Z","generator":{"displayName":"oauth:17","link":"
http://twitter.com
"},"provider":{"objectType":"service","displayName":"Twitter","link":"
http://www.twitter.com"},"link":"
http://twitter.com/FastestFood/statuses/3318543260","body":"Oregon Biz
Report » How Starbucks saved millions. Oregon closures ...
http://u.mavrev.com/02bdj","object":{"objectType":"note","id":"object:
search.twitter.com,2005:3318543260","summary":"Oregon Biz Report » How
Starbucks saved millions. Oregon closures ... http://u.mavrev.com/02bdj
","link":"http://twitter.com/FastestFood/statuses/3318543260
","postedTime":"2009-08-15T00:00:23.000Z"},"twitter_entities":{"urls":[{"expanded_url":null,"indices":[70,95],"url":"
http://u.mavrev.com/02bdj
"}],"hashtags":[],"user_mentions":[]},"retweetCount":0,"gnip":{"matching_rules":[{"value":"Starbucks","tag":null}]}}
{"info":{"message":"Replay Request
Completed","sent":"2015-02-18T00:05:15+00:00","activity_count":2}}

	[[alternative HTML version deleted]]



More information about the R-help mailing list