My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
             
New issue | Search
for
| Advanced search | Search tips
Issue 66: Deserializer too strict with string escapes???
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Oct 2008
Type-Defect
Priority-Medium


Sign in to add a comment
 
Reported by james.re...@gmail.com, Oct 21, 2008
The deserializer seems to be too strict (maybe not even compliant?) in
handling escapes in strings.

In particular, JSON feeds such as Twitter escape slashes in strings, and
gson complains of a syntax error on encountering them.

Although in theory only double-quotes, reverse solidusses (sp?), and
control characters need be escaped, the "official" JSON syntax at
http://www.json.org/ explicitly lists the slash as being acceptable when
escaped.

Ya, maybe JSON generators should not be escaping slashes. But in line with
a paraphrase of the Postel Principle ("Generate strictly, accept
leniently"). maybe gson should accept any character when escaped?

Just a thought, I could be wrong. Comments welcome and expected.

Jim Renkel
Comment 1 by william.pjyeh, Oct 29, 2008
Appendix E of "JavaScript: The Good Parts" said that:

"JSON allows the / character to be escaped so that JSON can be embedded in HTML
<script> tags. HTML does not allow the sequence </ except to start the </script> tag.
JSON allows <\/, which produces the same result but does not confuse HTML."


The solidum characters are escaped in other popular scripting languages (e.g., PHP).
So I think gson should consider it seriously.
Comment 2 by inder123, Oct 29, 2008
I agree this is a good idea. I have fixed this in r279 and also added a test. We will 
include it in our next release.
Status: Fixed
Sign in to add a comment

Hosted by Google Code