【发布时间】:2021-11-20 02:34:33
【问题描述】:
我不明白我在 String 中设置的所有内容。但仍然有这个问题。当我测试我的网络 API 时,这件事没有问题.. 但是当我实施时遇到了这个问题..
这是我的错误
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path
这是我调用 get Section 的代码
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long itemID) {
if (position >= 0 && position < goodModelArrayList.size()) {
String section= goodModelArrayList.get(position).getSection();
//getSelectedCategoryData(section);
restService.getService().getSection(section, new Callback<VW_AC_Line_>() {
@Override
public void success(VW_AC_Line_ student, Response response) {
Toast.makeText(Viewattendance.this, "success", Toast.LENGTH_LONG).show();
}
@Override
public void failure(RetrofitError error) {
Toast.makeText(Viewattendance.this, error.getMessage().toString(), Toast.LENGTH_LONG).show();
}
});
} else {
Toast.makeText(Viewattendance.this, "Selected Category Does not Exist!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
这里是我要调用的数据类
public class VW_AC_Line_ {
public int ID;
public String Section;
public int getID(){
return ID;
}
public void setID(int id){
this.ID = id;
}
public String getSection() {
return Section;
}
public void setSection(String section) {
this.Section = section;
}
}
这是我的调用方法web api
@GET("/api/VW_AC_LINE_/deparment/{section}")
public void getSection(@Path("section") String section, Callback<VW_AC_Line_> callback);
这里是 web api 调用
[{"ID":2665,"Section":"IT"}].
【问题讨论】:
标签: java android gson retrofit