File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
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 @@ -125,9 +125,16 @@ private List<String> tokenize(String json) {
125
125
int inObject = 0 ;
126
126
int inList = 0 ;
127
127
boolean inValue = false ;
128
+ boolean inEscape = false ;
128
129
StringBuilder build = new StringBuilder ();
129
130
while (index < json .length ()) {
130
131
char current = json .charAt (index );
132
+ if (inEscape ) {
133
+ build .append (current );
134
+ index ++;
135
+ inEscape = false ;
136
+ continue ;
137
+ }
131
138
if (current == '{' ) {
132
139
inObject ++;
133
140
}
@@ -147,6 +154,9 @@ private List<String> tokenize(String json) {
147
154
list .add (build .toString ());
148
155
build .setLength (0 );
149
156
}
157
+ else if (current == '\\' ) {
158
+ inEscape = true ;
159
+ }
150
160
else {
151
161
build .append (current );
152
162
}
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