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) {
125125 int inObject = 0 ;
126126 int inList = 0 ;
127127 boolean inValue = false ;
128+ boolean inEscape = false ;
128129 StringBuilder build = new StringBuilder ();
129130 while (index < json .length ()) {
130131 char current = json .charAt (index );
132+ if (inEscape ) {
133+ build .append (current );
134+ index ++;
135+ inEscape = false ;
136+ continue ;
137+ }
131138 if (current == '{' ) {
132139 inObject ++;
133140 }
@@ -147,6 +154,9 @@ private List<String> tokenize(String json) {
147154 list .add (build .toString ());
148155 build .setLength (0 );
149156 }
157+ else if (current == '\\' ) {
158+ inEscape = true ;
159+ }
150160 else {
151161 build .append (current );
152162 }
Original file line number Diff line number Diff line change @@ -170,4 +170,11 @@ public void listWithLeadingWhitespaceMapThrowsARuntimeException() {
170170 this .parser .parseList ("\n \t {}" );
171171 }
172172
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+
173180}
You can’t perform that action at this time.
0 commit comments