3

json ファイルからいくつかのデータを解析しています。これが私のJSONファイルです。

[
     {

       "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"
     }
]

データを1つずつ取得して保存できます。このように

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");
} 

name1)さて、私の質問は、単一のクエリで各配列のすべての値を取得する方法があるということです。2) でこれらすべての値を取得できますArrayか?

私が何か間違ったことをしている場合は、私を修正してください。ありがとうございました。

4

3 に答える 3