如何使用string-url名称 - 值对反序列化json

时间:2016-04-14 14:01:27

标签: java android json retrofit2

我有

形式的json响应
 {
  "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?.."                        
      }
    }
  ]
}

我可以解析expert []数组中的所有其他内容,除了“profile”,其值“http://...com/experts.svc/1.0/385816/..../json?..”具有以下json响应

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

使用的模型如下 主要的pojo:

public class ExpertObj
{
    private String total;

    private Category category;

    private Experts[] experts;    

}
  1. 类别pojo:

    公共类别 {

    private String id; 私有字符串名称;

    }

  2. 3.Experts array pojo:

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

    使用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();
    ....}
    

    如何解析profile-url名称 - 值对并在android中的详细布局中显示结果。 任何帮助表示赞赏。 新的android。如果没有正确解释,请原谅。

0 个答案:

没有答案
相关问题