Create JSON Array and JSON Object Android Studio : I'm getting data from an XML file and this is my code on parsing the XML, which I have no problems with. I'm not familiar with ArrayList so I stick with JSON.

    while (eventType != XmlPullParser.END_DOCUMENT)
        {
            if(eventType == XmlPullParser.START_DOCUMENT)
            {
                Log.e("XML READ","--- Start XML ---");
            }
            else if(eventType == XmlPullParser.START_TAG) {
                if (xpp.getName().toString().equals("question")) {
                    
                } else if (xpp.getName().toString().equals("choice")) {
                    try {
                        choices = new JSONObject();
                        choices.put("value", xpp.getAttributeValue(null, "value"));
                        choices.put("iscorrect", xpp.getAttributeValue(null, "iscorrect"));
                        jsonArray.put(choices);
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
    
            try {
                questions.put("questions", jsonArray);
            } catch (JSONException e) {
                e.printStackTrace();
            }
    
            try {
                eventType = xpp.next();
            } catch (XmlPullParserException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

I'm trying to create a JSON Object in this structure.

    {
        "question": [
            {
                "q": "what is 1 + 1?",
                "choices": [
                    {
                        "ans":"1",
                        "iscorrect":"false"
                    },
                    {
                        "ans":"2",
                        "iscorrect":"true"
                    }
                ]
            },
        ]
    }

I have based my code from this link
https://stackoverflow.com/questions/17810044/android-create-json-array-and-json-object

PS: Sorry for bad english
PPS: New to android