简体   繁体   English

使用Xstream忽略xml的某些字段

[英]Ignore some fields of xml using Xstream

I want to know if I can ignore fields using this method xstream.omitField(Class.class, "cUF"); 我想知道是否可以使用此方法xstream.omitField(Class.class, "cUF");忽略字段xstream.omitField(Class.class, "cUF"); because I have a list of fields to ignore, in the same class so how can I do that? 因为在同一个班级中我有一个要忽略的字段列表,所以我该怎么做?

I´m using xStream 我正在使用xStream

Thanks 谢谢

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. 如果不起作用,请尝试在类构造函数中的空String中设置该字段,然后再尝试尝试一下,如果对XML中的该字段起作用,您就知道问题可能出在哪里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM