我有XML请求字符串作为文本内容输入,但是Jackson将其标识为XML标签。我尝试使用JacksonXMLText,但这无济于事。
<Reference>
<Request><?xml version="1.0" encoding="UTF-8" ?><Quote
sess="JAKE_OSCAR_EU" language="ENG" Country="US">
</Quote>
</Request>
</Reference>
这让我感到异常
com.ctc.wstx.exc.WstxParsingException: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
答案 0 :(得分:2)
我认为您需要编写一个客户反序列化器,以读取要读取Raw的那部分树。这是一个示例实现:
@JsonSerialize(using = RawObjectSerializer.class)
@JsonDeserialize(using = RawObjectDeserializer.class)
public class RawObject {
public final String value;
public RawObject(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
公共类RawObjectDeserializer扩展了StdDeserializer {
public RawObjectDeserializer() {
super(RawObject.class);
}
@Override
public RawObject deserialize(JsonParser parser, DeserializationContext context) throws IOException {
return new RawObject(parser.getCodec().readTree(parser).toString());
}
}