[英]want to convert json string to json object containing xml
I want to convert json string to json object.我想将 json 字符串转换为 json 对象。 I am using the following method.我正在使用以下方法。
public List convertJsonToObject(String json) throws JsonParseException, JsonMappingException, IOException {
ObjectMapper mapper = new ObjectMapper();
List myObjects = mapper.readValue(json, new TypeReference>() {});
return myObjects;
}
The problem is that my json string has XML content in it, which gives error because of double quotes.问题是我的 json 字符串中包含 XML 内容,由于双引号而导致错误。 What should I do?我该怎么办?
You need to convert a valid json.您需要转换有效的 json。 I reformatted your incomplete JSON a bit.我重新格式化了您不完整的 JSON。 Please try this one.请试试这个。 You need to escape some characters.您需要转义一些字符。 The "
character needs to be escaped. "
字符需要转义。
[
{
"orderNo":"20139429260",
"sapRequest":"<?xml version=\"1.0\" encoding=\"UTF-8\" s..",
"customerResponse":"<?xml version=\"1.0\" e....
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.