Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way to transmit a map<string,map<string,integer>> along with application.properties is to convert the map into a JSON object and include it as a string value in the properties file.

For example, if the map is called "data", we can use the following code to convert it into a JSON string:

ObjectMapper objectMapper = new ObjectMapper();
String jsonData = objectMapper.writeValueAsString(data);

We can then include this JSON string as a value in the application.properties file using a key of our choice, like so:

my.map.data={JSON string here}

In the application code, we can then retrieve this JSON string, parse it back into the original map type, and use it in our application.