diff options
author | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-22 15:41:54 +0200 |
---|---|---|
committer | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-22 15:41:54 +0200 |
commit | ad6bb6d0d2da264656c5de0e51297997374a41d6 (patch) | |
tree | 90b988b6e63a60fdf60a7ed467f2130c31c619ad /src/main/TweetCounter.java | |
parent | 2b2a47a0086eab52b09e5425e75cafb488e51074 (diff) | |
download | TwitterDataAnalytics-ad6bb6d0d2da264656c5de0e51297997374a41d6.tar.gz |
Refactored JSON to GSON's implementation.
* Changed JSONException to JsonParseException.
Diffstat (limited to 'src/main/TweetCounter.java')
-rw-r--r-- | src/main/TweetCounter.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main/TweetCounter.java b/src/main/TweetCounter.java index 6c1397a..c630cda 100644 --- a/src/main/TweetCounter.java +++ b/src/main/TweetCounter.java @@ -1,12 +1,12 @@ package main; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; import java.util.Date; import java.util.HashSet; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import org.json.JSONException; -import org.json.JSONObject; import provider.ResultListener; /** @@ -29,14 +29,14 @@ public class TweetCounter implements ResultListener { } @Override - public void tweetGenerated(JSONObject obj) { - tweetCount++; + public void tweetGenerated(JsonObject obj) { try { - JSONObject userObj = obj.getJSONObject("user"); - String screen_name = userObj.getString("screen_name"); - users.add(screen_name); - } catch (JSONException ex) { - LOGGER.log(Level.WARNING, "Profile is missing data", ex); + JsonObject userObj = obj.getAsJsonObject("user"); + String screen_name = userObj.get("screen_name").getAsString(); + tweetCount++; + users.add(screen_name); + } catch (JsonParseException ex) { + LOGGER.log(Level.WARNING, "Profile is missing data", ex); } } |