Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing Twitter Public Timeline (JSON) into Java Objects via GSON
    text
    copied!<p>I've seen quite a few people having trouble with the GSON library - I still couldn't find a solution to my problem.</p> <p>What I'm trying to achieve is to parse JSON from <a href="http://twitter.com/statuses/public_timeline.json" rel="nofollow" title="Twitter's public timeline">Twitter's public timeline</a> into a POJO with GSON.</p> <p>The following is my representation of twitter's JSON structure:</p> <pre><code>public class OneTweet { public OneTweet() { // Empty constructor } public String coordinates; public String favorited; public String created_at; public String truncated; public String text; public String contributors; public String id; public String geo; public String in_reply_to_user_id; public String place; public String in_reply_to_screen_name; //public user user; public List&lt;user&gt; user; public String source; public String something; } </code></pre> <hr> <pre><code>public class user { public String name; public String profile_sidebar_border_color; public String profile_background_tile; public String profile_sidebar_fill_color; public String created_at; public String profile_image_url; public String location; public String profile_link_color; public String follow_request_sent; public String url; public String favourites_count; public String contributors_enabled; public String utc_offset; public String id; public String profile_use_background_image; public String profile_text_color; // protected is a reserved identifier public String pprotected; public String followers_count; public String lang; public String notifications; public String time_zone; public String verified; public String profile_background_color; public String geo_enabled; public String description; public String friends_count; public String statuses_count; public String profile_background_image_url; public String following; public String in_reply_to_status_id; public String screen_name; } </code></pre> <hr> <pre><code>Map&lt;String, OneTweet&gt; json_string_array = googlejson.fromJson(jsonstring, new TypeToken&lt;Map&lt;String, OneTweet&gt;&gt;(){}.getType()); </code></pre> <p>I currently get the following error:</p> <blockquote> <p>Exception in thread "main" com.google.gson.JsonParseException: Expecting object found: false</p> </blockquote> <p>I'm guessing either my POJO structure is wrong or maybe it has to do with the fact that the JSON object "protected" is a protected identifier in Java. If the latter is the case I wouldn't know how to fix it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload