Tag: snakeyaml

使用snakeYaml在根目录中解析带有映射的YAML文档

我想将YAML文档读取到自定义对象的地图(而不是默认情况下snakeYaml执行的地图)。 所以这: 19: typeID: 2 limit: 300 20: typeID: 8 limit: 100 将被加载到如下所示的地图: Map 其中项目是: class Item { private Integer typeId; private Integer limit; } 我找不到用snakeYaml做这个的方法,我也找不到更好的任务库。 该文档仅包含嵌套在其他对象中的maps / collections的示例,以便您可以执行以下操作: TypeDescription typeDescription = new TypeDescription(ClassContainingAMap.class); typeDescription.putMapPropertyType(“propertyNameOfNestedMap”, Integer.class, Item.class); Constructor constructor = new Constructor(typeDescription); Yaml yaml = new Yaml(constructor); /* creating an input stream (is) */ ClassContainingAMap […]