I want to fetch json from [this link][1]: https://api.myjson.com/bins/38ln5 using retrofit
sample json is
{
\"students\": [
{
\"id\": \"
Retrofit will automatically parse JSON Object as well JSON Array.
@GET("/register?email=example@123.com")
public void responseString(Callback response);
your model class looks like:
public class Student{
private ArrayList studentList = new ArrayList<>();
//getter and setters
}
public class StudentInfo{
private String id;
private String name;
//getters and setters
}
Then in response:
@Override
public void onResponse(Response response, Retrofit retrofit) {
if (response.isSuccess()) {
Student student = response.body;
Log.e("Student name", student.getStudent().get(0).getName()); // do whatever you want
}else{
// get response.errorBody()
}
}