discomarathon / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Newlines not converted to json properly in JsonObject.toString() #157

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

JsonObject obj = new JsonObject();
obj.addProperty("someProp", "multiline\nstring");
System.out.println(obj.toString());

What is the expected output? What do you see instead?

Expected Output: 

{"someProp":"multiline\nstring"}

Observed Output:

{"someProp":"multiline
string"}

What version of the product are you using? On what operating system?
Gson 1.3
Windows Vista

Please provide any additional information below.

Original issue reported on code.google.com by vish.ram...@gmail.com on 19 Sep 2009 at 1:48

GoogleCodeExporter commented 9 years ago
You should not expect valid JSON here.  Since the Gson object can be configured 
with
different escaping strategies, we recommend that you use the following function 
instead:
{@link Gson#toJson(JsonElement)}

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