开发者

Has anyone encountered a universal Object to String formatter for Java?

Has anyone encountered a universal Object to String formatter for Java? I'm imagining something that would use reflection to discovery properties开发者_如何学C of an arbitrary object (probably just a JavaBean, but probably including some properties which are Collections or Mapss) and format the object as a String? This is in a situation where I do not have any control over the toString() implementations of the target classes.

Does something like this exist somewhere?


Object serializers usually do exactly that. For example JSON serializes to text (JS more precisely) but there are others as well.


Try here.

Reflection is not the best choice regarding performance, though. Also, some classes' private members might be quite uninteresting and spam your output if they are included in the toString() return value.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜