我正在学习YouTube视频后的改造,但现在我被卡住了.它向我显示一个错误"改造预期的begin_array,但是在第1行第2列路径$的begin_object"我试图从这个站点获取json数据. http://servicio-monkydevs.rhcloud.com/clientes/
这是我的代码
MainActivity.java
resultadoTextView = (TextView) findViewById(R.id.Resultado);
Retrofit restAdapter = new Retrofit.Builder()
.baseUrl("http://servicio-monkydevs.rhcloud.com")
.addConverterFactory(GsonConverterFactory.create())
.build();
ClienteService service = restAdapter.create(ClienteService.class);
Call<Cliente> call = service.getCliente();
call.enqueue(new Callback<Cliente>() {
@Override
public void onResponse(Call<Cliente> call, Response<Cliente> response) {
if(response.isSuccessful()) {
resultadoTextView.setText(call.toString());
}else{
resultadoTextView.setText("algo paso");
}
}
@Override
public void onFailure(Call<Cliente> call, Throwable t) {
resultadoTextView.setText(t.getMessage());
}
});
Run Code Online (Sandbox Code Playgroud)
ClientService.java
public interface ClienteService {
@GET("/clientes")
Call<Cliente> getCliente();
}
Run Code Online (Sandbox Code Playgroud)
Client.java
public class Cliente {
private int id;
private String name;
private String username;
private String email; …Run Code Online (Sandbox Code Playgroud)