开发者

Java: Printing out an object for debugging

I would like an ea开发者_Python百科sy way to print out a java object, or to say it another way, serialize an object as a string. I would like to see the values of all variables contained within the object, and if there are more objects (like a list or whatever) it should print out the stuff in that object as well. Basically, it would be something like JSON encoding, but JSON doesn't support infinity, and I need to see if there is infinity or NaN in one of the double or float values.

How can I do this?


You could use Gson to serialize to JSON as it now supports NaN and +/- infinity


More often than not ToStringBuilder.reflectionToString(Object) works great. It wont work when doing Maps though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜