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 154: how to convert JsonObject to JSONString()?
4 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  joel.leitch
Closed:  Sep 23
Type-Defect
Priority-Medium


Sign in to add a comment
 
Reported by lxbzmy, Sep 09, 2009
call JsonObject.toString()  result is not a realy JSONString
because some char is not quoted!!!
Gson gson = new Gson();
JsonParser p = new JsonParser();

JsonElement r = p.parse("{\"text\":\"good\\n after\\nnoom\"}");
JsonObject ob = r.getAsJsonObject();

r.toString() \\ espect {"text":"good\\n after\\nnoom\"} but {"text":"good
after
noom\"}

Comment 1 by joel.leitch, Sep 23, 2009
 Issue 157  has been merged into this issue.
Comment 2 by joel.leitch, Sep 23, 2009
I will create a change to fix this to at least use the basic escaping according to
the JSON spec.

Since the Gson object can be configured to do extra escaping (i.e. HTML, JS, etc.),
you can always use the following method to generate valid JSON from some JsonElement
object:
{@link Gson#toJson(JsonElement)}
Status: Accepted
Owner: joel.leitch
Comment 3 by joel.leitch, Sep 23, 2009
Fix submitted with r446.
Status: Fixed
Comment 4 by joel.leitch, Sep 23, 2009
 Issue 107  has been merged into this issue.
Sign in to add a comment

Hosted by Google Code