Android GSON custom class json casting exception
I am attempting to write an Android app which casts JSON input. This is my
sample input.
I have the following class to serve as the data container:
public class DATA {
public Long id;
public String title;
public String author;
public String url;
public String date;
public String body;
public DATA() {
// TODO Auto-generated constructor stub
}
@Override
public String toString(){
return "DATA-Oblect: ID=> " + id + "/nTITLE=> " + title;
}
}
Using the followingline of code:
List<DATA> Data = new ArrayList<DATA>();
Data = Arrays.asList(gson.fromJson(reader, DATA[].class));
I get the following exception error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:
Can anyone tell me what I'm doing wrong, please?
No comments:
Post a Comment