@@ -71,7 +71,7 @@ public void enterJson(JSONParser.JsonContext ctx) {
7171 */
7272 @ Override
7373 public void enterPair (JSONParser .PairContext ctx ) {
74- String name = unquoteEmbeddedQuotes (StringUtils .stripQuotes (ctx .STRING ().getText ()));
74+ String name = resolveEscapeSequences (StringUtils .stripQuotes (ctx .STRING ().getText ()));
7575 currentPairName .push (name );
7676 }
7777
@@ -169,7 +169,7 @@ public void exitJsonArray(JSONParser.JsonArrayContext ctx) {
169169 */
170170 @ Override
171171 public void enterJsonString (JSONParser .JsonStringContext ctx ) {
172- String cleanString = unquoteEmbeddedQuotes (StringUtils .stripQuotes (ctx .STRING ().getText ()));
172+ String cleanString = resolveEscapeSequences (StringUtils .stripQuotes (ctx .STRING ().getText ()));
173173 currentScalarValue = new PyString (cleanString );
174174 currentValueType .push (ValueType .SCALAR );
175175 }
@@ -347,10 +347,17 @@ private void addToArrayIfNeeded() {
347347 }
348348 }
349349
350- private static String unquoteEmbeddedQuotes (String text ) {
350+ private static String resolveEscapeSequences (String text ) {
351351 String result = text ;
352352 if (!StringUtils .isEmpty (text )) {
353353 result = text .replace ("\\ \" " , "\" " );
354+ result = result .replace ("\\ \\ " , "\\ " );
355+ result = result .replace ("\\ b" , "\b " );
356+ result = result .replace ("\\ f" , "\f " );
357+ result = result .replace ("\\ n" , "\n " );
358+ result = result .replace ("\\ r" , "\r " );
359+ result = result .replace ("\\ t" , "\t " );
360+ result = result .replace ("\\ /" , "/" );
354361 }
355362 return result ;
356363 }
0 commit comments