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

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

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 1 comment
Closed

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 9 Jan 2013 at 5:11

@GoogleCodeExporter
Copy link
Author

Duplicate of 188, which I've bumped to "Critical" priority.

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

  • Changed state: Duplicate

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

No branches or pull requests

1 participant