Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to convert JsonObject to JSONString()? #154

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 4 comments
Closed

how to convert JsonObject to JSONString()? #154

GoogleCodeExporter opened this issue Mar 19, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

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\"}

Original issue reported on code.google.com by lxb...@gmail.com on 9 Sep 2009 at 9:56

@GoogleCodeExporter
Copy link
Author

Issue 157 has been merged into this issue.

Original comment by joel.leitch@gmail.com on 23 Sep 2009 at 5:27

@GoogleCodeExporter
Copy link
Author

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)}

Original comment by joel.leitch@gmail.com on 23 Sep 2009 at 5:31

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Fix submitted with r446.

Original comment by joel.leitch@gmail.com on 23 Sep 2009 at 6:28

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Issue 107 has been merged into this issue.

Original comment by joel.leitch@gmail.com on 23 Sep 2009 at 6:49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant