Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8425147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:11:32+00:00 2026-06-10T04:11:32+00:00

I’m trying to parse this json and crate a POJO from it. The online

  • 0

I’m trying to parse this json and crate a POJO from it. The online documentation has me confused. I suspect I am incorrectly handling the fact that there are many different occurances of the same type of object. Do I need an array? What would that look like? Here is my class so far:

public class StoryGSONClass {
private Response kind;

public static class Response {
    private String Listing;
    private Data data;
}

public static class Data {
    private String modhash;
    private Children children;
    private String after;
    private String before;
}

public static class Children {
    private String childKind;
    private ChildData childData;
}

public static class ChildData {
    private String domain;
    private String banned_by;
    private String media_embed;
    private String subreddit;
    private String selftext_html;
    private String selftext;
    private String likes;
    private String link_flair_text;
    private String id;
    private String clicked;
    private String title;
    private String num_comments;
    private String score;
    private String approved_by;
    private String over_18;
    private String hidden;
    private String thumbnail;
    private String subreddit_id;
    private String edited;
    private String link_flair_css_class;
    private String author_flair_css_class;
    private String downs;
    private String saved;
    private String is_self;
    private String permalink;
    private String name;
    private String created;
    private String url;
    private String author_flair_text;
    private String author;
    private String created_utc;
    private String media;
    private String num_reports;
    private String ups;
}

}

followed by

Gson gson = new Gson();    
StoryGSONClass target2 = gson.fromJson(objectName, StoryGSONClass.class);

Edit: here is the newest version of the class:

public class Response {
    private String kind;
    private ResponseData data;

public static class ResponseData {
    private String modhash;
    private List<ResponseChildData> children;
    private String after;
    private String before;
}

public static class ResponseChildData {
    private String kind;
    private ChildData data;
}

public static class ChildData {
    private String domain;
    private String banned_by;
    private Object media_embed;
    private String subreddit;
    private String selftext_html;
    private String selftext;
    private String likes;
    private String link_flair_text;
    private String id;
    private boolean clicked;
    private String title;
    private int num_comments;
    private int score;
    private String approved_by;
    private boolean over_18;
    private boolean hidden;
    private String thumbnail;
    private String subreddit_id;
    private boolean edited;
    private boolean link_flair_css_class;
    private boolean author_flair_css_class;
    private int downs;
    private boolean saved;
    private boolean is_self;
    private String permalink;
    private String name;
    private String created;
    private String url;
    private String author_flair_text;
    private String author;
    private String created_utc;
    private String media;
    private String num_reports;
    private int ups;
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:11:33+00:00Added an answer on June 10, 2026 at 4:11 am

    The main parent object should look something like this:

    public class Response {
        private String kind;
        private ResponseData data;
    
        ...
    }
    

    Then ResponseData is:

    public class ResponseData {
        private String modhash;
        private List<ResponseChildData> children; // I imagine this is where you're having
                                                  // some confusion. You can use a list here
                                                  // and you should be fine.
    
        ...
    }
    

    And ResponseChildData is:

    public class ResponseChildData {
        private String kind;
        private ChildData data; // This could be a Map<String, String>, but then you'd
                                // possibly lose type information. I haven't used GSON 
                                // enough to know if it would balk when it sees that some
                                // values are int and boolean and refuse to deserialize.
                                // Using a specific type here is probably better anyway
    
        ...
    }
    

    Finally, ChildData is:

    public class ChildData {
        private String domain;
        private String banned_by;
        ...
        ...
        private int ups;
    
        ...
    }
    

    Then you can do:

    Gson gson = new Gson();    
    Response target2 = gson.fromJson(objectName, Response.class);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.