Abydars / json-simple

Automatically exported from code.google.com/p/json-simple
Apache License 2.0
0 stars 0 forks source link

Missing escape of single-quote #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

   in method JSONValue.escape(String s, StringBuffer sb) I think you are missing the escape of single-quote character.

Here is the proposed patch:

Index: trunk/src/org/json/simple/JSONValue.java
===================================================================
--- trunk/src/org/json/simple/JSONValue.java    (revision 185)
+++ trunk/src/org/json/simple/JSONValue.java    (working copy)
@@ -231,6 +231,9 @@
            case '"':
                sb.append("\\\"");
                break;
+           case '\'':
+               sb.append("\\\'");
+               break;
            case '\\':
                sb.append("\\\\");
                break;

Let me know what do you think about.
Bye
Piero

Original issue reported on code.google.com by ottu...@gmail.com on 10 Aug 2011 at 2:34

GoogleCodeExporter commented 9 years ago
We don't have to escape single quote according to JSON spec.
See more details on http://www.json.org/

Original comment by fangyid...@gmail.com on 29 Nov 2011 at 3:19