I have an JSONArray that looks like this:

how can i convert that to a string?
if i try:
json.toString();
the string is:
["package.package.ChecklistModels.ChecklistAnswer@405dddd8","package.package.ChecklistModels.ChecklistAnswer@405ddf48","package.package.ChecklistModels.ChecklistAnswer@405de070","package.package.ChecklistModels.ChecklistAnswer@405de198","package.package.ChecklistModels.ChecklistAnswer@405de2c0","package.package.ChecklistModels.ChecklistAnswer@405de3e8","package.package.ChecklistModels.ChecklistAnswer@405de510"]
but i want something like this:
{
"json":
"values": [
{
"answer": "true",
"remark":"",
"questionId": "0"
"checklistId": "2"
},
{
"answer": "true",
"remark":"",
"questionId": "0"
"checklistId": "2"
}
]
}
EDIT:
this a snipped how i make the json array:
if(cb.isChecked() || !text.getText().toString().equals("")){
ChecklistAnswer answer = new ChecklistAnswer(questions.get(id).id, 2, cb.isChecked(), text.getText().toString());
answers.add(answer);
}
}
JSONArray json = new JSONArray(answers);
String jsonString = json.toString();
ChecklistAnswerobject into array ... notJSONObject...ChecklistAnswer.toString()returns "xx.xx.xx.ChecklistAnswer@XXX" ... so either override ChecklistAnswer.toString method to return json string or make a function to translate ChecklistAnswer to JSOObjectanswers.add(answer);useanswers.add(answer.toJSONObject());(and yeah, you have to writetoJSONObjectmethod insideChecklistAnswerby yourself - which should be pretty simple - like putting all ChecklistAnswer`s properties into new JSONObject)