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 8172805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:53:58+00:00 2026-06-06T21:53:58+00:00

This is my Json: { feed: [ { id: 124124124124, source: aaaaaa, comment_count: 0,

  • 0

This is my Json:

{

    "feed": [
        {
            "id": "124124124124",
            "source": "aaaaaa",
            "comment_count": 0,
            "link": "bbbbb",
            "created_time": "2012-05-30T15:57:05+0000",
            "message": "ccccc",
            "type": "dddd",
            "thumbnail": "eeeee"
        },
        {
            "id": "35464423423412414",
            "source": "qweqddq",
            "comment_count": 0,
            "link": "adadasdwe",
            "created_time": "2012-05-30T15:52:21+0000",
            "message": "dadsadad",
            "type": "sfdcsdv",
            "thumbnail": "csdgfsd"
        },
        {

    "name": "asdadqwff",
    "id": "73182372381",
    "source": "lajhdkbad",
    "comment_count": 0,
    "link": "adjkbxczckbj",
    "created_time": "2012-05-30T15:40:28+0000",
    "message": "awjasdjands",
    "type": "lalkdm",
    "thumbnail": "akmldsncj"

     }

    ]

  }

These are my java classes to use in parsing:

public class Feed {

    @SerializedName("feed")
    ArrayList<FeedResult> feed;

    public ArrayList<FeedResult> getFeed() {
        return feed;
    }

    public void setFeed(ArrayList<FeedResult> feed) {
        this.feed = feed;
    }   

}


public class FeedResult {

    @SerializedName("id")
    String id;

    @SerializedName("created_time")
    String created_time;

    @SerializedName("message")
    String message;

    @SerializedName("thumbnail")
    String thumbnail;

    @SerializedName("comment_count")
    String comment_count;


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCreated_time() {
        return created_time;
    }

    public void setCreated_time(String created_time) {
        this.created_time = created_time;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getThumbnail() {
        return thumbnail;
    }

    public void setThumbnail(String thumbnail) {
        this.thumbnail = thumbnail;
    }

    public String getComment_count() {
        return comment_count;
    }

    public void setComment_count(String comment_count) {
        this.comment_count = comment_count;
    }


}

This is the inside of main class:

InputStream source = retrieveStream(url);

            Gson gson=new Gson();

            Reader reader = new InputStreamReader(source);

            Feed feeds=gson.fromJson(reader,Feed.class);

            ArrayList<FeedResult>feed=new ArrayList<FeedResult>();

            feed=feeds.getFeed();

            Toast.makeText(this,"feed --> ?? "+ feed, Toast.LENGTH_LONG).show();

feeds.getFeed() returns null. Why is that? thanks for your help already.

  • 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-06T21:54:00+00:00Added an answer on June 6, 2026 at 9:54 pm

    instead of giving inputstream directly to the GSON constructor, download the JSON string first from the URL and then pass it to the constructor for parsing as below:

    String source = read(url);
    Feed feeds=new Gson().fromJson(source ,Feed.class);
    ArrayList<FeedResult>feed=new ArrayList<FeedResult>();
    feed=feeds.getFeed();
    for(FeedResult feedResult:feedResults)
        System.out.println(feedResult);
    

    the read function:

    public static String read(String url){
    
        System.out.println("Connecting to service URL : "+url);
        InputStream is = null;
        String result = "";
        // http post
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(url);
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
    
        } catch (Exception e) {
            e.printStackTrace();
        }
    
        // convert response to string
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            result = sb.toString();
    
        } catch (Exception e) {
            e.printStackTrace();
        }
    
    
        return result;
    }
    

    add toString() function in your FeedResult class, so that it will get printed to console in readable manner:

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "FeedResult [id=" + id + ", created_time=" + created_time
                + ", message=" + message + ", thumbnail=" + thumbnail
                + ", comment_count=" + comment_count + "]";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get the regular title and regular body from this JSON feed.
I have a json feed from this URL which contains 20 fields and I
How can i convert this JSON array: This is a serialized JSON array 2012-06-18
i have this JSON object: {error:null, result:[{id:1234567890, count:1, recipients: [u3848, u8958, u7477474 ], dateCreated:2012-06-13T09:13:45.989Z
I have this json object : { msg_id:134, message:Dick, comment:[ { com_id:9, comment:test, msg_id:134,
I have an array of dictionaries from a JSON feed. This populates a UITableView
I have a JSON feed that drupal spits out time in this format: 2010-12-16T04:41:35Z
I got from a json feed this : <img src = http://produits-lemieux.com/produits/bainmoussant_hg.jpg ></img> i
this is my json feed i need to store the email and password in
I am getting this data back in a valid json feed. "start":"10/16/2011 11:00:00 PM","end":"10/16/2011

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.