我有一个Java类
@JsonIgnoreProperties(ignoreUnknown = true)
public class LogMessage {
private String timestamp;
private String level;
private String message;
private String loggername;
private String thread;
}
以下代码:
ObjectMapper objectMapper = new ObjectMapper();
....
objectMapper.readValue(m, LogMessage.class);
当消息字段包含JSON格式数据时,将引发期望。
处理问题的好方法是什么?