【问题标题】:Is there a way to ignore the superclass properties in Snake yaml有没有办法忽略 Snake yaml 中的超类属性
【发布时间】:2020-02-11 02:25:09
【问题描述】:

我尝试如下设置表示器

Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);

但它仍然在一些我无法控制的超类属性上失败。

【问题讨论】:

    标签: parsing yaml snakeyaml


    【解决方案1】:

    尝试使用TypeDescription 告诉 SnakeYAML 它应该跳过超类属性:

    final td = new TypeDescription(MyClass.class);
    td.setExcludes("property1", "property2" /* ... */);
    representer.addTypeDescription(td);
    

    MyClass 是子类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-17
      • 2020-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多