Need a way to escape dots in property keys (add path separator configuration)
See original GitHub issueI want to create a map from properties using JavaPropsMapper, which works as long as the keys for the map don’t contain dots.
I have something like this:
Config expResult = new Config(
new Config.Server(17, "/path", "param1", "param2", "Wobble")
, ImmutableMap.<String, String>builder().put("x.y", "y").put("a.b", "b").build()
);
System.setProperty("server.arg", "param1");
System.setProperty("map.x.y", "y");
And when I run that through the JavaPropsMapper it falls over because it creates:
{"map":{"x":{"y":"y"}}}
when what I want is:
{"map":{"x.y":"y"}}
(I want to have domain names as keys)
It would be nice if there was some way to escape the dots in property names so that they weren’t considered to be delimiters. I could probably make this work by configuring a completely different delimiter, but that would just confuse anyone wanting to work with this.
Things I’ve tried, any of which would be an OK solution for me, are:
System.setProperty("map[x.y]", "y");
System.setProperty("map.[x.y]", "y");
System.setProperty("map.x\\.y", "y");
System.setProperty("map.'x.y'", "y");
System.setProperty("map.x'.'y", "y");
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:18 (18 by maintainers)
Top Results From Across the Web
Escaping a dot in a Map key in Yaml in Spring Boot
Above keys are parsed as standard properties. As a work around, you can use Spring's YamlMapFactoryBean to create a Yaml Map as it...
Read more >File paths in Godot projects
This page explains how file paths work inside Godot projects. You will learn how to access paths in your projects using the res://...
Read more >Expressions - Apache FreeMarker Manual
Specify values directly. Often you want to specify a value directly and not as a result of some calculations. Strings. To specify a...
Read more >Spring Boot application.properties file | Dev in Web
Custom separator for list properties. By default, Spring splits your property by the comma. There is no way to escape comma.
Read more >Spring Cloud Config Server
The most convenient way to add the dependency is with a Spring Boot starter ... Cloud Config Client, you need to set the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh, I’m sorry, I’d missed all of those. Yes, that seems to work just fine.
Ok no problem. Glad they work for you.