snakeyaml

Parsing a YAML document with a map at the root using snakeYaml

陌路散爱 提交于 2019-11-29 06:42:11
I want to read a YAML document to a map of custom objects (instead of maps, which snakeYaml does by default). So this: 19: typeID: 2 limit: 300 20: typeID: 8 limit: 100 Would be loaded to a map which looks like this: Map<Integer, Item> where Item is: class Item { private Integer typeId; private Integer limit; } I could not find a way to do this with snakeYaml, and I couldn't find a better library for the task either. The documentation only has examples with maps/collections nested inside other objects, so that you can do the following: TypeDescription typeDescription = new TypeDescription

Parsing a YAML document with a map at the root using snakeYaml

99封情书 提交于 2019-11-28 00:31:55
问题 I want to read a YAML document to a map of custom objects (instead of maps, which snakeYaml does by default). So this: 19: typeID: 2 limit: 300 20: typeID: 8 limit: 100 Would be loaded to a map which looks like this: Map<Integer, Item> where Item is: class Item { private Integer typeId; private Integer limit; } I could not find a way to do this with snakeYaml, and I couldn't find a better library for the task either. The documentation only has examples with maps/collections nested inside