Помогите, пожалуйста, я получаю нулевую ссылку на объект для класса / объекта Properties. Мне нужно изменить текстовое представление с помощью объекта вопроса, но я получаю ошибку нулевой ссылки.
Спасибо за любую помощь
JSON Объект ответа
publi c class PersonalityApiReponse {
public class Info
{
// Quiz Description
private String description;
// Quiz Getter
public String getDescription()
{
return description;
}
}
public Definitions getDefinitions() {
return definitions;
}
private Definitions definitions;
public class Definitions
{
private QuestionnaireDataResult questionnaireDataResult;
public QuestionnaireDataResult getQuestionnaireDataResult() {
return questionnaireDataResult;
}
public class QuestionnaireDataResult
{
public Properties getProperties() {
return properties;
}
private Properties properties;
public class Properties
{
public Questions getQuestions() {
return questions;
}
private Questions questions;
public class Questions
{ //Questions Attributes
public Example[] example;
//Getter
public Example[] getExample()
{ return example;}
//Example Class
public class Example
{ //Example Attributes
private int questionId;
private String questionText;
public Responses[] responses;
//Getter for Example Attributes
public int getQuestionId()
{ return questionId; }
public String getQuestionText()
{ return questionText; }
public Responses[] getResponses()
{ return responses; }
public class Responses
{ private String responseText;}
}
}
}
}
}
}
Строка запроса залпа url = "https://api-store.evalueproduction.com/store/api-docs/EValue/RiskQuestionnaireProfiler/1.0.0";
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Gson gson = new Gson();
PersonalityApiReponse personalityApiReponse = gson.fromJson(response,PersonalityApiReponse.class);
//Parsing the String into UX
TextView question = findViewById(R.id.questiontxtV);
TextView question1 = findViewById(R.id.questiontxtV1);
TextView question2 = findViewById(R.id.questiontxtV2);
TextView question3 = findViewById(R.id.questiontxtV3);
TextView question4 = findViewById(R.id.questiontxtV4);
TextView question5 = findViewById(R.id.questiontxtV5);
//Setting values
PersonalityApiReponse.Definitions.QuestionnaireDataResult question_object =
personalityApiReponse.getDefinitions().getQuestionnaireDataResult();
PersonalityApiReponse.Definitions.QuestionnaireDataResult.Properties properties = question_object.getProperties();
PersonalityApiReponse.Definitions.QuestionnaireDataResult.Properties.Questions api_question_object = properties.getQuestions();
PersonalityApiReponse.Definitions.QuestionnaireDataResult.Properties.Questions.Example [] examples = api_question_object.getExample();
PersonalityApiReponse.Definitions.QuestionnaireDataResult.Properties.Questions.Example example1 = examples[0];
question.setText(example1.getQuestionText());
requestQueue.stop();
}
};