GSA サーバーから次の XML 応答があります。基本的にそれは持っています
<GSP>
<RES>
<M>
<R id=1>
</R>
<R id=2>
</R>
</RES>
</GSP>
この XML を Jackson で解析するにはどうすればよいですか? これが私のコードです
@XmlRootElement(name = "GSP")
@JsonIgnoreProperties(ignoreUnknown = true)
public class RespuestaGSARoot {
@JacksonXmlProperty(localName = "RES")
private ResultadoBusqueda res;
}
@JacksonXmlRootElement(localName = "RES")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResultadoBusqueda {
@JacksonXmlProperty(localName = "M")
private int total;
@JacksonXmlProperty(localName = "R")
private List<ResultadoPagina> resultados;
}
@XmlRootElement(name = "R")
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResultadoPagina {
@JacksonXmlProperty(localName = "U")
private String url;
@JacksonXmlProperty(localName = "T")
private String titulo;
@JacksonXmlProperty(localName = "S")
private String descripcion;}
これらはすべてセッターとゲッターを持っていますが、これは単なる例です。私は RES まで行くことができますが、フィールド "resultados" に R の結果のリストが入りません。このエラーが発生します:
com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class com.tm.buscador.domain.ResultadoPagina] from String value ('http://negocios.movistar.com.ar/tienda/lineas-y-planes/comunidad-negocios-full/'); no single-String constructor/factory method
at [Source: java.io.StringReader@642f9a77; line: 20, column: 99] (through reference chain: com.tm.buscador.domain.RespuestaGSARoot["RES"]->com.tm.buscador.domain.ResultadoBusqueda["R"]->java.util.ArrayList[0])