我在json解析中遇到问题。我正在使用凌空来获取数据,并使用gson将数据放入Java对象中。我的代码没有任何错误, 但是我通过凌空接收所有数据,但是gson从json数据中仅复制了数组中的3个元素。
这是获取数据的代码
ExternalTexture
这是对象
public void get_Standing_data(final Context context,String league){
final Workdone workdone= (Workdone) context;
final String Url = "http://api.football-data.org/v2/competitions/"+league+"/standings";
final RequestQueue queue = Volley.newRequestQueue(context);
final StringRequest request = new StringRequest(Url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
CompetitionStanding data=null;
Log.d("fetched data", "onResponse: " + response);
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.create();
data = gson.fromJson(response, CompetitionStanding.class);
workdone.standing_done(data);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
workdone.standing_notdone();
// Toast.makeText(context, "something went wrong", Toast.LENGTH_SHORT).show();
}
}){
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("X-Auth-Token", key);
params.put("Accept", "application/json");
return params;
}
};
queue.add(request);
}
这是api的响应
public class CompetitionStanding {
@SerializedName("filters")
@Expose
private Filters filters;
@SerializedName("competition")
@Expose
private Competition competition;
@SerializedName("season")
@Expose
private Season season;
@SerializedName("standings")
@Expose
private List<Standing> standings = null;
public Filters getFilters() {
return filters;
}
public void setFilters(Filters filters) {
this.filters = filters;
}
public Competition getCompetition() {
return competition;
}
public void setCompetition(Competition competition) {
this.competition = competition;
}
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
public List<Standing> getStandings() {
return standings;
}
public void setStandings(List<Standing> standings) {
this.standings = standings;
}
}
,但是仅从此json复制3个元素 我做错什么了吗? 任何帮助将不胜感激