如何在Jackson中记录JSON反序列化

时间:2021-05-28 18:03:35

I have a piece of code that is reading JSON data from an input stream and converting it to POJOs (using Jackson). Sometimes, the data will fail to deserialize and it's difficult to troubleshoot. What would be a good mechanism to see the line-by-line input stream in log4j? Are there other tools/techniques that can help the troubleshooting?

我有一段代码从输入流中读取JSON数据并将其转换为POJO(使用Jackson)。有时,数据将无法反序列化,并且很难进行故障排除。在log4j中查看逐行输入流的好机制是什么?是否有其他工具/技术可以帮助进行故障排除?

1 个解决方案

#1


0  

Apache Commons IOUtils will convert your input stream to a String, which you can then pass to log4j.

Apache Commons IOUtils会将您的输入流转换为String,然后您可以将其传递给log4j。

String theString = IOUtils.toString(inputStream, encoding);

#1


0  

Apache Commons IOUtils will convert your input stream to a String, which you can then pass to log4j.

Apache Commons IOUtils会将您的输入流转换为String,然后您可以将其传递给log4j。

String theString = IOUtils.toString(inputStream, encoding);