Issues with LinkedTreeMap object returned from RetroFit library

When i try to access the results with reviewdata.result.get("results") it expects an object and wont let me iterate through results =( ! I am looking for a way to get the resuluts node into a structure I can use. Any help is appreciated.

0 = {LinkedTreeMap$Node@3888} "page" -> "1.0"
1 = {LinkedTreeMap$Node@3889} "results" -> " size = 2"
2 = {LinkedTreeMap$Node@3890} "total_pages" -> "1.0"
3 = {LinkedTreeMap$Node@3891} "total_results" -> "2.0"  

Answers


Here is the complete code if anyone else runs into this issue when trying to work with gson Linked Tree Maps =D !

    LinkedTreeMap treemap = reviewdata.result;
    ArrayList<LinkedTreeMap> subtree = (ArrayList<LinkedTreeMap>) treemap.get("results");
    ArrayList<Review> reviews = new ArrayList<>();

    for(LinkedTreeMap map : subtree){
        Review review = new Review();
        review.setReviewID(map.get("id").toString());
        review.setAuthor(map.get("author").toString());
        review.setContent(map.get("content").toString());
        review.setURL(map.get("url").toString());
        reviews.add(review);
    }

    return  reviews;

This workaround worked for me:

Class<M> modelClass;
final List<M> modelList = new ArrayList<>();

@Override
public void success(List<Object> resultList, Response response) {
    modelList.clear();
    for (Object result : resultList) {
        String json = new Gson().toJson(result);
        M model = new Gson().fromJson(json, modelClass);
        modelList.add(model);
    }
    Log.wtf(TAG, "GET Successful");
}

Need Your Help

How to show an RDLC report in C# Report Viewer with a vertical scroll bar?

c# pdf reporting rdlc

I have generated a 9 page report using RDLC reports in C# VS 2010, but what I want is a vertical scroll bar so that I scroll down the pages like PDF instead of Page Next/ Previous button. I am sear...

how to allow a null values in multi valued parameter

reporting-services ssrs-2008 fetchxml

I have a requirement to include a null value in multi valued parameter. I'm using fetchXML code in my dataset. Please help me with it.