-3

How to parse a json array without object tags? How can I get files?

{
    "id": "476",
    //IDобращения"status": "2",
    //Статус: 0=>'Нарассмотрении',
    1=>'Вработе',
    2=>'Выполнено',
    3=>'Отклонено'"latitude": "56.007831",
    //геокоординаты,
    заданныеприподачеобращения"longitude": "35.970359",
    "message": "dfghdfgh",
    //текстобращения"published_at": "2014-01-30 18:13:29",
    //датаподачиобращения"comments": [
        {
            "id": 133,
            "message": "aaa",
            //тексткомментария(админ/пользователь)"isadmin": "0",
            //ответданадминистратором(isadmin=1)"curr_status": "1"//статусобращениянамоментответа
        },
        {
            "id": 134,
            "message": "112",
            "isadmin": "1",
            "curr_status": "1"
        },
        {
            "id": 136,
            "message": "",
            "isadmin": "1",
            "curr_status": "2"
        },
        {
            "id": 137,
            "message": "123",
            "isadmin": "1",
            "curr_status": "2"
        }
    ],
    "files": [
        “”,
        ””……””//image(base64encoded)
    ]
}

  JSONObject result = new JSONObject(s);
            id = result.getInt("id");
            status = result.getInt("status");
            latitude = result.getDouble("latitude");
            longitude = result.getDouble("longitude");
            message = result.getString("message");
            dateOfPublish = result.getString("published_at");
            JSONArray jsonArray = result.getJSONArray("files");

            for (int j = 0; j < jsonArray.length(); j++) {
                //Here i want to get files
            }
Ahmad
  • 69,608
  • 17
  • 111
  • 137
Kostya Khuta
  • 673
  • 2
  • 7
  • 21

2 Answers2

1

Try calling this method. That should do it.

JSONArray.get

peter.petrov
  • 38,363
  • 16
  • 94
  • 159
0

you should try this (I didn't test it):

    for(int n = 0; n < JSONArray.length(); n++)
    {
       JSONObject object = JSONArray.getJSONObject(n);
       String file = object.get("");
       // do some stuff....
    }
ahmed_khan_89
  • 2,755
  • 26
  • 49