Expected BEGIN_OBJECT but was STRING at line 1 column 22 path $.time
@Override
protected void onPostExecute(String s) {
Gson gson=new Gson();
Test model=gson.fromJson(s,Test.class);
tv.setText(model.getName());
}
实体类:
public class Test {
private String name;
private Calendar time;
...
...
}
原因是因为这里的Test里面有一个Calendar对象,造成了无法解析,可以把他换成Date类型即可
public class Test {
private String name;
private Date time;
...
...
}