String eventType = event.getUserEventType().toString();
String author = event.getAuthors().get(0).getName();
String videoId = event.getVideoId();
String username = event.getUsername();
String title = event.getTitle().getPlainText();
Rating rating = event.getRating();
Date updated = new Date(event.getUpdated().getValue());
JSONObject json = new JSONObject();
try {
json.put("event", eventType);
json.put("title", title);
if(username != null) {
json.put("username", username);
}
if(rating != null) {
json.put("rating", rating.getValue());
}
if(videoId != null) {
json.put("videoid", videoId);
}
} catch (JSONException e) {