I have this JSON array object response
{ "Exam":[
{
"mock_test":
[
{
id: "14",
option_a: "android developer",
option_b: "programmer",
option_c: "coder",
option_d: "developer",
is_correct: "1",
question_number: "14",
questions: "hello this pavan sharma",
},
{
id: "14",
option_a: "android developer",
option_b: "programmer",
option_c: "coder",
option_d: "developer",
is_correct: "1",
question_number: "14",
questions: "hello this pavan sharma",
},
{
id: "14",
option_a: "android developer",
option_b: "programmer",
option_c: "coder",
option_d: "developer",
is_correct: "1",
question_number: "14",
questions: "hello this pavan sharma",
},
]
},
{
"mock_test":
[
{
id: "14",
option_a: "android developer",
option_b: "programmer",
option_c: "coder",
option_d: "developer",
is_correct: "1",
question_number: "14",
questions: "hello this pavan sharma",
},
{
id: "14",
option_a: "android developer",
option_b: "programmer",
option_c: "coder",
option_d: "developer",
is_correct: "1",
question_number: "14",
questions: "hello this pavan sharma",
},
{
id: "14",
option_a: "android developer",
option_b: "programmer",
option_c: "coder",
option_d: "developer",
is_correct: "1",
question_number: "14",
questions: "hello this pavan sharma",
},
]
}
]}
I have created model class like
public class ModelClass implements Serializable {
@SerializedName("id")
@Expose
private int id;
@SerializedName("option_a")
@Expose
private String option_a;
@SerializedName("option_b")
@Expose
private String option_b;
@SerializedName("option_c")
@Expose
private String option_c;
public ModelClass(int id, String option_a, String option_b, String option_c) {
this.id = id;
this.option_a = option_a;
this.option_b = option_b;
this.option_c = option_c;
}
public int getId() {
return id;
}
public String getOption_a() {
return option_a;
}
public String getOption_b() {
return option_b;
}
public String getOption_c() {
return option_c;
}}
another model class is
public class DataModelClass {
@SerializedName("mock_test")
@Expose
private ArrayList<ModelClass> mockTest=null;
public DataModelClass(ArrayList<ModelClass> mockTest) {
this.mockTest = mockTest;
}
public ArrayList<ModelClass> getMockTest() {
return mockTest;
}
another model class is
public class MainModelClass implements Serializable {
@SerializedName("Exam")
@Expose
private ArrayList<DataModelClass> exam=null;
public MainModelClass(ArrayList<DataModelClass> exam) {
this.exam = exam;
}
public ArrayList<DataModelClass> getExam() {
return exam;
}
In MainActivity
apiInterface=ApiClient.getRetrofitInstance().create(API.class);
Call<DataModelClass> call = apiInterface.getEmpData();
call.enqueue(new Callback<DataModelClass>() {
@Override
public void onResponse(Call<DataModelClass> call, Response<DataModelClass> response) {
progressDialog.dismiss();
}
@Override
public void onFailure(Call<DataModelClass> call, Throwable t) {
Toast.makeText(getApplicationContext(),""+t,Toast.LENGTH_SHORT).show();
}
});
please tell me how can i call inner object like id,option_a, option_b, option_c etc... i can create recycler view for this but i just want to know how to call these inner objects.
JSONyou provided, the whole response from API? Are you successfully getting the response from Retrofit? Or maybe you cannot get the response form Retrofit because your models are not properly written?