我正在尝试使用翻新将json解析为POJO,但始终出现错误。
它似乎得到了数据,据我从logcat所看到的,我正确读取并解析了json。但是它返回succes = false,并且不返回responsedata对象。
错误类型和错误消息为空。
我不知道出什么问题了,希望能对解决方案提出任何建议或如何找到错误。

杰森

{
  "competition_info": {
    "headline": "competition",
    "description": "description for competition.",
    "accept_button": "OK",
    "open_terms_button": "Open info"
  },
  "terms": {
    "html": "a website in html"
  }
    }


MyPojo

public class AnnComResponses{
    @SerializedName("competition_info")
    public CompetitionInfo competitionInfo;
    @SerializedName("terms")
    public Terms terms;

    public class Terms{

        @SerializedName("html")
        public String html;

        public String getTerms() {
            return html;
        }
    }

    public class CompetitionInfo{
        @SerializedName("headline")
        public String headline;
        @SerializedName("description")
        public String description;
        @SerializedName("accept_button")
        public String acceptButton;
        @SerializedName("open_terms_button")
        public String openTermsButton;

        public String getHeadline() {
            return headline;
        }

        public String getDescription() {
            return description;
        }

        public String getAcceptButton() {
            return acceptButton;
        }

        public String getOpenTermsButton() {
            return openTermsButton;
        }

    }
}

最佳答案

尝试对GSON转换器进行如下改造:

RestAdapter restAdapter = new RestAdapter.Builder()
                .setLogLevel(RestAdapter.LogLevel.FULL)
                .setConverter(new GsonConverter(new GsonBuilder()).create()))
                .setEndpoint("your api end point goes here")
                .build();
YourAPI api = restAdapter.create(YourAPI.class);

07-25 23:55
查看更多