I have a data model with that is a String[]. When I try to convert the model into JSONObject using the following code:
public class CheckList {
private String id = "123";
private String Q1 = "This is Question 1";
private String[] Q2 = ["Part 1", Part 2"];
public CheckList (String, id, String Q1, String[] Q2){
...
}
}
CheckList checklist = new Checklist("123", "This is Question 1", ["Part 1", "Part 2"]
JSONObject test = new JSONObject(checklist);
the String[] is not being converted properly. With the code above, I want a JSONObject look like this:
{
id: 123,
Q1: This is Question 1,
Q2: [Part 1, Part 2]
}
but I'm getting JSONObject like this:
{
id: 123,
Q1: This is Question 1,
Q2: [{"bytes":[{},{},{},{}],"empty":false},{"bytes":[{},{},{},{}],"empty":false}]
}
Is there any way to fix this issue? Thanks in advance.