I have this object which is converted into following format but it does not wrap it properly.
我有这个对象,它被转换成以下格式,但它没有正确包装。
@JsonProperty("code")
private String code;
@JsonProperty("message")
private String msg;
@JsonProperty("assign")
private SomeVO someVO;
//getter, setters
to this format:
这种格式:
{
"status": {
"code": $value,
"message": $value
},
"data":{
"assign" {
"schemaLayoutFileName" : $value
"dataStoreTargetLocationText" : $value
}
}
}
How can it be done?
如何做呢?
1 个解决方案
#1
2
The class you have defined does not match the JSON you want to parse. Try the following design (if the class attributes names match the JSON properties names, you won't need @JsonProperty
):
您定义的类与要解析的JSON不匹配。尝试以下设计(如果类属性名称与JSON属性名称匹配,则不需要@JsonProperty):
public class Foo {
private Status status;
private Data data;
// Getters and setters
}
public class Status {
private String code;
private String value;
// Getters and setters
}
public class Data {
private Assign assign;
// Getters and setters
}
public class Assign {
private String schemaLayoutFileName;
private String dataStoreTargetLocationText;
// Getters and setters
}
#1
2
The class you have defined does not match the JSON you want to parse. Try the following design (if the class attributes names match the JSON properties names, you won't need @JsonProperty
):
您定义的类与要解析的JSON不匹配。尝试以下设计(如果类属性名称与JSON属性名称匹配,则不需要@JsonProperty):
public class Foo {
private Status status;
private Data data;
// Getters and setters
}
public class Status {
private String code;
private String value;
// Getters and setters
}
public class Data {
private Assign assign;
// Getters and setters
}
public class Assign {
private String schemaLayoutFileName;
private String dataStoreTargetLocationText;
// Getters and setters
}