注意,这与封送属性对象无关。
我想要一种房产格式。示例:
class Foo { String a = "aaa"; Item i = new Item(); }
class Item { String val = "Value"; }
marshall( new 转到
a = Hello
i.value = Value我知道这种方法有其局限性,但没关系。
,有这样的东西吗?
如果没有,是否有一些简单的表达式语言库,既可以在对象树中查询对象,也可以识别“字符串键”?
我查过BeanUtils了-什么都没有。
发布于 2012-09-29 06:47:33
为此,可以使用objectprops(http://code.google.com/p/objectprops/):
ObjectPropertiesStore store = new ObjectPropertiesStore();
// write the object to the store
store.writeObject(new Foo());
// let's get the Properties object and print the contents to System.out
Properties properties = store.getDatabase();
properties.store( System.out, "My test");或者,您可以使用ReflectionToStringBuilder of commons轻松地实现这一点,并传递您自己实现的自定义ToStringStyle,并将得到的字符串加载到属性对象中。
https://stackoverflow.com/questions/12650245
复制相似问题