Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.6
    • Fix Version/s: None
    • Component/s: lang.*
    • Labels:

      Description

      It would be great to offer a StringEscapeUtils.escapeJson method which is similar to StringEscapeUtils.escapeJavaScript but will not escape apostrophe (single-quote) chars.

      The current escapeJavaScript method does escape single-quote chars, but this produces invalid JSON. A good description of the problem can be found here:

      http://stackoverflow.com/questions/2275359/jquery-single-quote-in-json-response

      1. LANG-797.patch
        7 kB
        Maurizio Cucchiara

        Issue Links

          Activity

          Hide
          Maurizio Cucchiara added a comment -

          Not yet Lukasz Lenart

          Show
          Maurizio Cucchiara added a comment - Not yet Lukasz Lenart
          Hide
          Lukasz Lenart added a comment -

          Does a new version with this fix was already released?

          Show
          Lukasz Lenart added a comment - Does a new version with this fix was already released?
          Hide
          Henri Yandell added a comment -

          Thanks Maurizio.

          svn ci -m "Added escape/unescapeJson methods per Maurizio Cucchiara's patch in LANG-797"
          Sending src/changes/changes.xml
          Sending src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
          Sending src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java
          Transmitting file data ...
          Committed revision 1467206.

          Show
          Henri Yandell added a comment - Thanks Maurizio. svn ci -m "Added escape/unescapeJson methods per Maurizio Cucchiara's patch in LANG-797 " Sending src/changes/changes.xml Sending src/main/java/org/apache/commons/lang3/StringEscapeUtils.java Sending src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java Transmitting file data ... Committed revision 1467206.
          Hide
          Maurizio Cucchiara added a comment -

          The attached patch should fix the issue.

          Show
          Maurizio Cucchiara added a comment - The attached patch should fix the issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              Joe Littlejohn
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development