discomarathon / google-gson

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

JsonObject toString method doesn't escape double quotes #182

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Create the following code:
 JsonObject jsonObj = new JsonObject();
 jsonObj.add("quotes", new JsonPrimitive("this is a double quote:'\"'"));
 System.out.println(jsonObj.toString());

I expected this string to be printed:
 {"quotes":"this is a double quote:'\"'"}

however i get this one instead:
 {"quotes":"this is a double quote:'"'"}

It's odd because if I have an object (non JsonObject) with a field with
quotes and i use GsonBuilder to convert it into a string it correctly
escapes the double quotes.

I am using version 1.3.

Please provide any additional information below.

Original issue reported on code.google.com by rafael.c...@gmail.com on 24 Dec 2009 at 12:59

GoogleCodeExporter commented 9 years ago
Using version 1.4 it works!

Original comment by rafael.c...@gmail.com on 22 Jan 2010 at 2:27

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 20 Aug 2010 at 5:35