You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When binding to `Map` properties, if the `key` contains anything other than lowercase alpha-numeric characters or `-`, you need to use the bracket notation so that the original value is preserved.
1493
-
If the key is not surrounded by `[]`, any characters that are not alpha-numeric or `-` are removed.
1494
-
For example, consider binding the following properties to a `Map`:
1492
+
When binding to `Map` properties you may need to use a special bracket notation so that the original `key` value is preserved.
1493
+
If the key is not surrounded by `[]`, any characters that are not alpha-numeric, `-` or `.` are removed.
1494
+
1495
+
For example, consider binding the following properties to a `Map<String,String>`:
1495
1496
1496
1497
1497
1498
[source,properties,indent=0,role="primary"]
@@ -1507,14 +1508,18 @@ For example, consider binding the following properties to a `Map`:
1507
1508
----
1508
1509
acme:
1509
1510
map:
1510
-
"[/key1]": value1
1511
-
"[/key2]": value2
1512
-
"/key3": value3
1511
+
"[/key1]": "value1"
1512
+
"[/key2]": "value2"
1513
+
"/key3": "value3"
1513
1514
----
1514
1515
1516
+
NOTE: For YAML files, the brackets need to be surrounded by quotes for the keys to be parsed properly.
1517
+
1515
1518
The properties above will bind to a `Map` with `/key1`, `/key2` and `key3` as the keys in the map.
1519
+
The slash has been removed from `key3` because it wasn't surrounded by square brackets.
1516
1520
1517
-
NOTE: For YAML files, the brackets need to be surrounded by quotes for the keys to be parsed properly.
1521
+
You may also occasionally need to use the bracket notation if your `key` contains a `.` and you are binding to non-scalar value.
1522
+
For example, binding `a.b=c` to `Map<String, Object>` will return a Map with the entry `{"a"={"b"="c"}}` where as `[a.b]=c` will return a Map with the entry `{"a.b"="c"}`.
0 commit comments