robospice解析嵌套对象响应

时间:2014-07-24 21:43:42

标签: android json robospice

我有一个服务器返回的JSON对象,如:

{
 "success":true,
 "value1":1,
 "otherValues":{
     "var1":1,
     "var2":"asd",
     "var3":2
 }

}

我应该如何建模响应类以接受所有值?例如

package com.phoneme.API.popIndex;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class GetResponse {
    private String success
    private String value1;
    private ??? otherValues;

    //GETTERS AND SETTERS of each
}

1 个答案:

答案 0 :(得分:1)

您尝试解码的响应无效JSON。需要引用字段名称。例如: -

{
     "success":true,
     "value1":1,
     "otherValues":{
         "var1":1,
         "var2":"asd",
         "var3":2
     }
 }

使用此更正版本的邮件,您可以在此处生成您的POJO: - http://www.jsonschema2pojo.org/

祝你好运!