Q:

How to get Strings from Array in JSON Object

How to get all the names from JSON object as a string array 
 {
    "status_code": 200,
    "status": "success",
    "data": [
      {
    "id": 1,
    "name": "Ajay"
    },
      {
    "id": 2,
    "name": "Balaji"
    },
      {
    "id": 3,
    "name": "Vinoth"
    }
    ]
    }

Expected Output : 
["Ajay","Balaji","Vinoth"]

A:

it's easy and You can retrieve your desired output like this
the symbol {,} mean json object and [,] indicate an json array 
      //Here i first take json object from your string

        JSONObject jsonObject = new JSONObject(your_json_respons_string);

      // now the json object have json array so we will take array

        JSONArray jsonArray = jsonObject.getJSONArray("data");

//each json array have one name so definitely our array size going to be jsonArray.length()

        String[] strings = new String[jsonArray.length()];

        for (int i = 0; i < jsonArray.length(); i++) {

      //taking json object and the name values and then putting in array

            JSONObject jsonObject1 = jsonArray.getJSONObject(i);
            strings[i] = jsonObject1.getString("name");

        }

