I am trying to parse wrong json string to the data class. Ideally it should throw JsonSyntaxException but its
class MyStudent{
int age;
int marks;
Student(int a, int m){
age = a;
marks = m;
}
}
I am parsing "{name:test}" and this returns me Object of MyStudent with no data inside it.
Gson gson = new Gson();
try {
return gson.fromJson(json, MyStudent.class);
} catch (JsonSyntaxException e) {
return null;
}
Can someone please let me know isn't this expected?