Hello,
I am using a filter query to parse the twitter streaming API. It doesn't appear that I'm getting valid JSON back as it starts with
metadata about the source/spout, etc... " source:spout:3.....
So I get an error JSONArray text must start with '[' at 1 [character 2 line 1]
I'm using the starter project
For my code I'm just setting the tuple toString and errors out when instantiating JSON Array
String urlContents = tuple.toString();
System.out.println("TUPLE=="+urlContents);
try {
// parse JSON
JSONArray jsonArray = new JSONArray(urlContents);
// use
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
System.out.println(jsonObject.getString("id"));
System.out.println(jsonObject.getString("text"));
System.out.println(jsonObject.getString("created_at"));
source: spout:3, stream: default, id: {}, [StatusJSONImpl{createdAt=Thu Jul 12 23:11:47 EDT 2012, id=223615680690397184, text='@XXX be money', source='web', isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=279363091, isFavorited=false, inReplyToScreenName='user', geoLocation=null, place=null, retweetCount=0, wasRetweetedByMe=false, contributors=null, annotations=null, retweetedStatus=null, userMentionEntities=[UserMentionEntityJSONImpl{start=0, end=13, name='Tweet User', screenName='jxxx', id=999999}], urlEntities=[], hashtagEntities=[], user=UserJSONImpl{id=9999, name='Oak', screenName='xx_sender', location='null', description='null', isContributorsEnabled=false, profileImageUrl='
http://a0.twimg.com/sticky/default_profile_images/default_profile_5_normal.png', profileImageUrlHttps='
https://si0.twimg.com/sticky/default_profile_images/default_profile_5_normal.png', url='null', isProtected=false, followersCount=1, status=null, profileBackgroundColor='C0DEED', profileTextColor='333333', profileLinkColor='0084B4', profileSidebarFillColor='DDEEF6', profileSidebarBorderColor='C0DEED', profileUseBackgroundImage=true, showAllInlineMedia=false, friendsCount=2, createdAt=Tue Jul 10 19:52:52 EDT 2012, favouritesCount=0, utcOffset=-1, timeZone='null', profileBackgroundImageUrl='
http://a0.twimg.com/images/themes/theme1/bg.png', profileBackgroundImageUrlHttps='
https://si0.twimg.com/images/themes/theme1/bg.png', profileBackgroundTiled=false, lang='en', statusesCount=6, isGeoEnabled=false, isVerified=false, translator=false, listedCount=0, isFollowRequestSent=false}}]
2012-07-12 23:12:00 STDIO [ERROR] twitter4j.internal.org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]