Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
cc996ce7
Commit
cc996ce7
authored
Jan 10, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend YAML map key special cases to nested maps
Fixes gh-208
parent
ff3af47e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
YamlProcessor.java
...n/java/org/springframework/boot/config/YamlProcessor.java
+6
-2
YamlProcessorTests.java
...a/org/springframework/boot/config/YamlProcessorTests.java
+13
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/config/YamlProcessor.java
View file @
cc996ce7
...
...
@@ -169,13 +169,17 @@ public class YamlProcessor {
Map
<
String
,
Object
>
result
=
new
LinkedHashMap
<
String
,
Object
>();
Map
<
Object
,
Object
>
map
=
(
Map
<
Object
,
Object
>)
object
;
for
(
Entry
<
Object
,
Object
>
entry
:
map
.
entrySet
())
{
Object
value
=
entry
.
getValue
();
if
(
value
instanceof
Map
)
{
value
=
asMap
(
value
);
}
Object
key
=
entry
.
getKey
();
if
(
key
instanceof
CharSequence
)
{
result
.
put
(
key
.
toString
(),
entry
.
getValue
()
);
result
.
put
(
key
.
toString
(),
value
);
}
else
{
// It has to be a map key in this case
result
.
put
(
"["
+
key
.
toString
()
+
"]"
,
entry
.
getValue
()
);
result
.
put
(
"["
+
key
.
toString
()
+
"]"
,
value
);
}
}
return
result
;
...
...
spring-boot/src/test/java/org/springframework/boot/config/YamlProcessorTests.java
View file @
cc996ce7
...
...
@@ -76,4 +76,17 @@ public class YamlProcessorTests {
});
}
@Test
public
void
integerDeepKeyBehaves
()
{
this
.
processor
.
setResources
(
new
Resource
[]
{
new
ByteArrayResource
(
"foo:\n 1: bar"
.
getBytes
())
});
this
.
processor
.
process
(
new
MatchCallback
()
{
@Override
public
void
process
(
Properties
properties
,
Map
<
String
,
Object
>
map
)
{
assertEquals
(
"bar"
,
properties
.
get
(
"foo[1]"
));
assertEquals
(
1
,
properties
.
size
());
}
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment