samujjwal / google-gson

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

convert string to JSON with special character \u #629

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Run this java code:
JsonParser parser = new JsonParser();
 JsonElement element = parser.parse("{\"description\":\"c:\\userDescription.txt\"}");
 JsonObject attributes = element.getAsJsonObject();
 System.out.println(attributes);

Expected output:
{"description":"c:\userDescription.txt"}

but actually, I see:
Exception in thread "main" com.google.gson.JsonSyntaxException: 
java.lang.NumberFormatException: For input string: "serD"

 I use Gson 1.5.

Please provide any additional information below.

Original issue reported on code.google.com by nhutnguy...@gmail.com on 3 Mar 2015 at 4:34