You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Hans Aikema (Jira)" <ji...@apache.org> on 2021/09/07 20:42:00 UTC

[jira] [Created] (TEXT-213) Unnecessary escaping of solidus in StringEscapeUtils.escapeJson

Hans Aikema created TEXT-213:
--------------------------------

             Summary: Unnecessary escaping of solidus in StringEscapeUtils.escapeJson
                 Key: TEXT-213
                 URL: https://issues.apache.org/jira/browse/TEXT-213
             Project: Commons Text
          Issue Type: Improvement
            Reporter: Hans Aikema


escapeJson escapes for JSON and states in the comment
{quote}The only difference between Java strings and Json strings is that in Json, forward-slash ( / ) is escaped.
{quote}
 
 However the JSON RFC referenced in the same comment (https://www.ietf.org/rfc/rfc4627.txt) states
{quote}The representation of strings is similar to conventions used in the C
 family of programming languages. A string begins and ends with
 quotation marks. All Unicode characters may be placed within the
 quotation marks except for the characters that must be escaped:
 quotation mark, reverse solidus, and the control characters (U+0000
 through U+001F).
{quote}
and a while later for the reproduction rules:
{quote}unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
{quote}
So the forward slash (%x2F) is allowed to be escaped, but not required to be. In order to minimize the size of JSON strings it would be better to not escape them and save the space used by the escape character.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)