Pratha-Shukla / google-gson

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

Why Gson doesn't throw a JsonSyntaxException on wrong types #495

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.have a JsonString like 
String json = "{"error":"something bad happened"}";

2. have a Java class like
class Dummy{
    private String foo;
}

3. calling Gson.fromJson(json, Dummy.class);

What is the expected output? What do you see instead?
I expect to get a JsonSyntaxException like stated in the docs:
"Throws:
    JsonSyntaxException - if json is not a valid representation for an object of type classOfT
"
but recieve a Dummy where foo==null

What version of the product are you using? On what operating system?
gson 1.7.1, Android/Linux

for further information, see stackoverflow question:
http://stackoverflow.com/questions/14242236/let-gson-throw-exceptions-on-wrong-t
ypes

Original issue reported on code.google.com by Raf...@gmail.com on 9 Jan 2013 at 5:11

GoogleCodeExporter commented 9 years ago
Duplicate of 188, which I've bumped to "Critical" priority.

Original comment by limpbizkit on 4 Feb 2013 at 4:01