How to define a map in a YAML file for a simple POJO?

I use snakeYaml to parse specific configuration values ​​/ properties for a Configuration object.

My yaml file looks like this:

#Thread batchLimit: 1000 threadCountLimit: 2 #Some More Config key: value #MAP keyMapping: <What goes here?> 

My configuration class is as follows:

 public class Configuration{ int batchlimit; int threadCountLimit; ... Map<String,String> keyMapping; } 

How to define keyMapping in a YAML file so that it reads directly through SnakeYAML?

+5
source share
1 answer

Here's what it might look like:

 #MAP keyMapping: key1: value1 key2: value2 

Typically, the YAML format has native support for key-value pairs. Take a look at the following tutorial (for example, for example): https://github.com/Animosity/CraftIRC/wiki/Complete-idiot's-introduction-to- YAML

Or just google "yaml map" for more details.

+16
source

Source: https://habr.com/ru/post/1238486/


All Articles