Android Volley nad Genson Web Service

时间:2017-08-31 10:39:17

标签: java json android-volley

我正试图从Volson和Genson的json webservist中提取数据。但它不会给出错误,但它不会提取数据。问题出在这里。任何人都可以帮助我。

private void GetData()
{
RequestQueue queue = Volley.newRequestQueue(this);
final String url = "https://api.github.com/users/mralexgray/repos";
StringRequest postRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>()
{
@Override
public void onResponse(String response) {
// response
Log.d("Response", response);
ParseData(response);
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error) {
// error
Log.d("Error.Response", error.getLocalizedMessage());
}
}
)
{
};
queue.add(postRequest);
}
private void ParseData(String data)
{
Genson genson = new Genson();
try {
Servis[] persons = genson.deserialize(data, Servis[].class);
}
catch (Exception e)
{
String hata = e.getLocalizedMessage();
}
}
public class Servis implements Serializable {
public String id;
public String name;
public String full_name;
}

0 个答案:

没有答案