Json 映射异常无法从START_ARRAY令牌中反序列化实例
我正在尝试将我的 json 请求解析为我的模型。我不知道,这段代码中有什么问题。json的语法看起来是正确的,Java模型上的注释也是如此。我不知道为什么我得到这样的错误:
Caused by: org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of ParametersType out of START_ARRAY token
(through reference chain: Document["parameters"])
Java模型:
@JsonIgnoreProperties( ignoreUnknown = true )
public class Document {
@XmlElement( required = true )
@JsonProperty( "templateId" )
protected String templateId;
@JsonProperty( "parameters" )
@XmlElement( required = true )
protected ParametersType parameters;
@JsonProperty( "documentFormat" )
@XmlElement( required = true )
protected DocumentFormatType documentFormat;
...}
@JsonIgnoreProperties( ignoreUnknown = true )
public class ParametersType {
@JsonProperty( "parameter" )
protected List<ParameterType> parameter;
...}
@JsonIgnoreProperties( ignoreUnknown = true )
public class ParameterType {
@XmlElement( required = true )
@JsonProperty( "key" )
protected String key;
@XmlElement( required = true )
@JsonProperty( "value" )
@XmlSchemaType( name = "anySimpleType" )
protected Object value;
@JsonProperty( "type" )
@XmlElement( required = true, defaultValue = "STRING_TYPE" )
protected ParamType type;
....}
Json 代码:
{
"templateId": "123",
"parameters": [
{
"parameter": [
{
"key": "id",
"value": "1",
"type": "STRING_TYPE"
},
{
"key": "id2",
"value": "12",
"type": "STRING_TYPE"
}
]
}
],
"documentFormat": "PDF"
}