How to deserialize json with a string-url name-value pair

南笙酒味 提交于 2019-12-12 03:46:46

问题


I have json response in the form

 {
  "total": 782,
  "category": {
    "id": 1120,
    "name": "Computers & Programming"
  },
  "experts": [
    {
      "id": 385816,
      "name": "Master Z",
      "title": "Mr",
      "description": " Expert in C++",
      "profile": "http://...com/experts.svc/1.0/385816/..../json?.."                        
      }
    }
  ]
}

I am able to parse everything else in the experts[] array except "profile" whose value "http://...com/experts.svc/1.0/385816/..../json?.." has the following json response

{
  "id": 385816,
  "name": "Master Z",
  "title": "",
  "reviewsCount": 15359,
  "averageRating": 4.87,
  "status": 4,
  "fee": 19.99,
  "languages": "English",
  "category": {
    "id": 1120,
    "name": "Computers & Programming"
  }
}

The models used are as follows 1. main pojo:

public class ExpertObj
{
    private String total;

    private Category category;

    private Experts[] experts;    

}
  1. Category pojo:

    public class Category {

    private String id; private String name;

    }

3.Experts array pojo:

   public class Experts
{
    private String id;
    private String name;
    private String title;
    private String description;
    private String profile;
}

Am using Retrift 2.

private RestManager mManager;
List<Expert> mExperts = new ArrayList<>();

....

Call<ExpertsObj> call = mManager.getExpertsService().listAllExperts();
        call.enqueue(new Callback<ExpertsObj>() {
            @Override
            public void onResponse(Call<ExpertsObj> call, Response<ExpertsObj> response) {
                if (response.isSuccess()) {
                    ExpertsObj expertsObj = response.body();

                    mExperts = expertsObj.getExperts();
....}

At a loss how to parse the profile-url name-value pair and display the results in a detail layout in android. Any help is appreciated. New in android. Please excuse if anything is not explained properly.

来源:https://stackoverflow.com/questions/36625488/how-to-deserialize-json-with-a-string-url-name-value-pair

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!