question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need a way to escape dots in property keys (add path separator configuration)

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
Yaytaycommented, Oct 8, 2022

Oh, I’m sorry, I’d missed all of those. Yes, that seems to work just fine.

0reactions
cowtowncodercommented, Oct 9, 2022

Ok no problem. Glad they work for you.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found