Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ private Map<String, Object> asMap(Object object) {
value = asMap(value);
}
if (key instanceof CharSequence) {
result.put(key.toString(), value);
String keyString = key.toString();
result.put((keyString.startsWith("[") ? "[" + keyString + "]" : keyString), value);
}
else {
// It has to be a map key in this case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,21 @@ void loadArrayOfObject() {
assertThat(properties.get("foo")).isNull();
}

@Test
void loadNestedMapWithBracketedKey() {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new ByteArrayResource("""
root:
webservices:
"[domain.test:8080]":
- username: me
password: mypassword
""".getBytes()));
Properties properties = factory.getObject();
assertThat(properties.getProperty("root.webservices[[domain.test:8080]][0].username")).isEqualTo("me");
assertThat(properties.getProperty("root.webservices[[domain.test:8080]][0].password")).isEqualTo("mypassword");
}

@Test
@SuppressWarnings("unchecked")
void yaml() {
Expand Down