Holen Sie sich sub-array aus JSON

Ich analysieren einige Daten aus einer json-Datei. Hier ist meine JSON-Datei.

[
     {

       "topic": "Example1", 
       "contact": [
            {
                "ref": [
                    1
                ], 
                "corresponding": true, 
                "name": "XYZ"
            }, 
            {
                "ref": [
                    1
                ], 
                "name": "ZXY"
            }, 
            {
                "ref": [
                    1
                ], 
                "name": "ABC"
            }, 
            {
                "ref": [
                    1, 
                    2
                ], 
                "name":"BCA"
            }
        ] , 

        "type": "Presentation"
     }, 
    {

       "topic": "Example2", 
       "contact": [
            {
                "ref": [
                    1
                ], 
                "corresponding": true, 
                "name": "XYZ"
            }, 
            {
                "ref": [
                    1
                ], 
                "name": "ZXY"
            }, 
            {
                "ref": [
                    1
                ], 
                "name": "ABC"
            }, 
            {
                "ref": [
                    1, 
                    2
                ], 
                "name":"BCA"
            }
        ] , 

        "type": "Poster"
     }
]

Kann ich Daten Holen und speichern. Wie diese

JSONArray getContactsArray = new JSONArray(jsonObject.getString("contact"));
for(int a =0 ; a < getContactsArray.length(); a++)
{
    JSONObject getJSonObj = (JSONObject)getContactsArray.get(a);
    String Name = getJSonObj.getString("name");
} 

1)Nun meine Frage gibt es eine Möglichkeit, um alle name Werte für die Arrays mit einzelnen Abfrage.
2) Kann ich alle diese Werte in einem Array ?

Bitte korrigieren Sie mich, wenn ich mache etwas falsch. Danke.

InformationsquelleAutor user2579475 | 2013-07-16

Schreibe einen Kommentar