I want to know if I can ignore fields using this method xstream.omitField(Class.class, "cUF");
because I have a list of fields to ignore, in the same class so how can I do that?
我想知道我是否可以使用此方法xstream.omitField(Class.class,“cUF”)忽略字段;因为我有一个要忽略的字段列表,在同一个类中,我该怎么做呢?
I´m using xStream
我正在使用xStream
Thanks
1 个解决方案
#1
0
Maybe there are some fields that contains null values, I had the same problem, and What I made the conclusion that Xstream try to access directly to the fields value, I mean it does not acces by setter or getter, try something, before of make your xml, set to a empty String the field : ""
也许有一些字段包含空值,我有同样的问题,我得出的结论是Xstream试图直接访问字段值,我的意思是它不能通过setter或getter访问,尝试之前,make你的xml,设置为空字符串字段:“”
object.setField("");
If it does not working, try to set the field in an empty String in the class constructor, just fro trying, if with that appers the field in your XML you have an idea where your problem could be.
如果它不起作用,尝试在类构造函数中设置一个空字符串中的字段,只是为了尝试,如果使用该字段在XML中的字段,您就可以了解问题所在。
#1
0
Maybe there are some fields that contains null values, I had the same problem, and What I made the conclusion that Xstream try to access directly to the fields value, I mean it does not acces by setter or getter, try something, before of make your xml, set to a empty String the field : ""
也许有一些字段包含空值,我有同样的问题,我得出的结论是Xstream试图直接访问字段值,我的意思是它不能通过setter或getter访问,尝试之前,make你的xml,设置为空字符串字段:“”
object.setField("");
If it does not working, try to set the field in an empty String in the class constructor, just fro trying, if with that appers the field in your XML you have an idea where your problem could be.
如果它不起作用,尝试在类构造函数中设置一个空字符串中的字段,只是为了尝试,如果使用该字段在XML中的字段,您就可以了解问题所在。