public void testJson() {
ObjectMapper mapper = new ObjectMapper();
try {
String htmlString = mapper.readValue("<!Doctype>", String.class);
} catch (IOException e) {
e.printStackTrace();
}
}
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: (String)"";
如何解决这个问题?
最佳答案
我最终使用了 gson。
JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
关于java - 无法使用 objectmapper 从 html 字符串读取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58122135/