XStream: UnknownFieldException - No such field

阅读更多

解决办法重写wrapMapper方法

return new XStream() {  
            @Override  
            protected MapperWrapper wrapMapper(MapperWrapper next){  
                return new MapperWrapper(next) {  
                    @Override  
                    public boolean shouldSerializeMember(Class definedIn, String fieldName){  
                        if (definedIn == Object.class){  
                            try {  
                                return this.realClass(fieldName) != null;  
                            } catch (Exception e){  
                                return false;  
                            }  
                        } else {  
                            return super.shouldSerializeMember(definedIn, fieldName);  
                        }  
                    }  
                };  
            }  
        };  

 

你可能感兴趣的:(Xstream,xml,No,such,field)