File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
spring-boot-project/spring-boot/src
main/java/org/springframework/boot/json
test/java/org/springframework/boot/json Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -113,9 +113,16 @@ private List<String> tokenize(String json) {
113
113
int inObject = 0 ;
114
114
int inList = 0 ;
115
115
boolean inValue = false ;
116
+ boolean inEscape = false ;
116
117
StringBuilder build = new StringBuilder ();
117
118
while (index < json .length ()) {
118
119
char current = json .charAt (index );
120
+ if (inEscape ) {
121
+ build .append (current );
122
+ index ++;
123
+ inEscape = false ;
124
+ continue ;
125
+ }
119
126
if (current == '{' ) {
120
127
inObject ++;
121
128
}
@@ -135,6 +142,9 @@ private List<String> tokenize(String json) {
135
142
list .add (build .toString ());
136
143
build .setLength (0 );
137
144
}
145
+ else if (current == '\\' ) {
146
+ inEscape = true ;
147
+ }
138
148
else {
139
149
build .append (current );
140
150
}
Original file line number Diff line number Diff line change @@ -170,4 +170,11 @@ public void listWithLeadingWhitespaceMapThrowsARuntimeException() {
170
170
this .parser .parseList ("\n \t {}" );
171
171
}
172
172
173
+ @ Test
174
+ public void escapeQuote () {
175
+ String input = "{\" foo\" : \" \\ \" bar\\ \" \" }" ;
176
+ Map <String , Object > map = this .parser .parseMap (input );
177
+ assertThat (map .get ("foo" )).isEqualTo ("\" bar\" " );
178
+ }
179
+
173
180
}
You can’t perform that action at this time.
0 commit comments