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
0a8a0daf
Commit
0a8a0daf
authored
Nov 07, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
Closes gh-18913
parents
dd4377e6
a11661d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
BasicJsonParser.java
...n/java/org/springframework/boot/json/BasicJsonParser.java
+3
-3
AbstractJsonParserTests.java
...rg/springframework/boot/json/AbstractJsonParserTests.java
+11
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java
View file @
0a8a0daf
...
@@ -49,7 +49,7 @@ public class BasicJsonParser extends AbstractJsonParser {
...
@@ -49,7 +49,7 @@ public class BasicJsonParser extends AbstractJsonParser {
private
List
<
Object
>
parseListInternal
(
String
json
)
{
private
List
<
Object
>
parseListInternal
(
String
json
)
{
List
<
Object
>
list
=
new
ArrayList
<>();
List
<
Object
>
list
=
new
ArrayList
<>();
json
=
trimLeadingCharacter
(
trimTrailingCharacter
(
json
,
']'
),
'['
);
json
=
trimLeadingCharacter
(
trimTrailingCharacter
(
json
,
']'
),
'['
)
.
trim
()
;
for
(
String
value
:
tokenize
(
json
))
{
for
(
String
value
:
tokenize
(
json
))
{
list
.
add
(
parseInternal
(
value
));
list
.
add
(
parseInternal
(
value
));
}
}
...
@@ -97,7 +97,7 @@ public class BasicJsonParser extends AbstractJsonParser {
...
@@ -97,7 +97,7 @@ public class BasicJsonParser extends AbstractJsonParser {
private
Map
<
String
,
Object
>
parseMapInternal
(
String
json
)
{
private
Map
<
String
,
Object
>
parseMapInternal
(
String
json
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
json
=
trimLeadingCharacter
(
trimTrailingCharacter
(
json
,
'}'
),
'{'
);
json
=
trimLeadingCharacter
(
trimTrailingCharacter
(
json
,
'}'
),
'{'
)
.
trim
()
;
for
(
String
pair
:
tokenize
(
json
))
{
for
(
String
pair
:
tokenize
(
json
))
{
String
[]
values
=
StringUtils
.
trimArrayElements
(
StringUtils
.
split
(
pair
,
":"
));
String
[]
values
=
StringUtils
.
trimArrayElements
(
StringUtils
.
split
(
pair
,
":"
));
String
key
=
trimLeadingCharacter
(
trimTrailingCharacter
(
values
[
0
],
'"'
),
'"'
);
String
key
=
trimLeadingCharacter
(
trimTrailingCharacter
(
values
[
0
],
'"'
),
'"'
);
...
@@ -151,7 +151,7 @@ public class BasicJsonParser extends AbstractJsonParser {
...
@@ -151,7 +151,7 @@ public class BasicJsonParser extends AbstractJsonParser {
index
++;
index
++;
}
}
if
(
build
.
length
()
>
0
)
{
if
(
build
.
length
()
>
0
)
{
list
.
add
(
build
.
toString
());
list
.
add
(
build
.
toString
()
.
trim
()
);
}
}
return
list
;
return
list
;
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/AbstractJsonParserTests.java
View file @
0a8a0daf
...
@@ -101,6 +101,17 @@ abstract class AbstractJsonParserTests {
...
@@ -101,6 +101,17 @@ abstract class AbstractJsonParserTests {
.
parseMap
(
"{\"foo\":[{\"foo\":\"bar\",\"spam\":1},{\"foo\":\"baz\",\"spam\":2}]}"
);
.
parseMap
(
"{\"foo\":[{\"foo\":\"bar\",\"spam\":1},{\"foo\":\"baz\",\"spam\":2}]}"
);
assertThat
(
map
).
hasSize
(
1
);
assertThat
(
map
).
hasSize
(
1
);
assertThat
(((
List
<
Object
>)
map
.
get
(
"foo"
))).
hasSize
(
2
);
assertThat
(((
List
<
Object
>)
map
.
get
(
"foo"
))).
hasSize
(
2
);
assertThat
(
map
.
get
(
"foo"
)).
asList
().
allMatch
(
Map
.
class
::
isInstance
);
}
@SuppressWarnings
(
"unchecked"
)
@Test
void
nestedLeadingAndTrailingWhitespace
()
{
Map
<
String
,
Object
>
map
=
this
.
parser
.
parseMap
(
" {\"foo\": [ { \"foo\" : \"bar\" , \"spam\" : 1 } , { \"foo\" : \"baz\" , \"spam\" : 2 } ] } "
);
assertThat
(
map
).
hasSize
(
1
);
assertThat
(((
List
<
Object
>)
map
.
get
(
"foo"
))).
hasSize
(
2
);
assertThat
(
map
.
get
(
"foo"
)).
asList
().
allMatch
(
Map
.
class
::
isInstance
);
}
}
@Test
@Test
...
...
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