title: populate json array in android spinner
body: <p>I am getting problem to parse json in android spinner. I have tried by below listed code but I am getting full json array in spinner like screenshot</p>
  
  <p><img src="https://i.stack.imgur.com/2CFn0.png" alt="click to see result"></p>
  
  <p><strong>My Json Array</strong></p>
  
  <pre><code>{"Department":[{"1":"Computer"},{"2":"IT"},{"3":"Civil"}]} // like this type json string
  </code></pre>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>public class GetDropdownItems extends AsyncTask&lt;Void, Void, String[]&gt; {
          public GetDropdownItems() {
              super();
          }
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              Log.i("MY_NETWORK", "first");
          }
  
          @Override
          protected String[] doInBackground(Void... params) {
              StringBuilder sbstaffdep = new StringBuilder();
              String staffdepURL = StaticDataEntity.URL_GETDEP;
              String charset = "UTF-8";  // Or in Java 7 and later, use the constant: java.nio.charset.StandardCharsets.UTF_8.name()
              URLConnection connectionstaffDep = null;
              try {
                  connectionstaffDep = new URL(staffdepURL).openConnection();
              } catch (IOException e) {
                  e.printStackTrace();
              }
  
              connectionstaffDep.setDoOutput(true); // Triggers POST.
              connectionstaffDep.setRequestProperty("Accept-Charset", charset);
              connectionstaffDep.setConnectTimeout(6000);
  
              InputStream responsestaffDep = null;
              try {
                  responsestaffDep = connectionstaffDep.getInputStream();
              } catch (IOException e) {
                  e.printStackTrace
                          ();
                  return new String[]{"unreachable"};
  
              }
  
              BufferedReader brstaffDep = new BufferedReader(new InputStreamReader(responsestaffDep));
              String readstaffDep;
              try {
  
                  while ((readstaffDep = brstaffDep.readLine()) != null) {
                      //System.out.println(read);
                      sbstaffdep.append(readstaffDep);
                  }
              } catch (IOException e) {
                  e.printStackTrace();
              }
  
              try {
  
                  brstaffDep.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              String[] finaldata = new String[1];
              finaldata[0] = sbstaffdep.toString();
              return finaldata;
          }
  
          @Override
          protected void onPostExecute(String[] s) {
              super.onPostExecute(s);
  
              if (s[0].equals("unreachable")) {
                  new SweetAlertDialog(SignUpStaff.this, SweetAlertDialog.ERROR_TYPE)
                          .setTitleText("Oops...")
                          .setContentText("Unable to connect to server ! \n Please try again later.")
                          .setCancelText("Ok")
                          .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
                              @Override
                              public void onClick(SweetAlertDialog sweetAlertDialog) {
                                  sweetAlertDialog.cancel();
                              }
                          })
                          .show();
                  return;
              }
              Log.i("MY_NETWORK", s.toString());
              String[] dataofdropdowndep = s[0].split(",");
              ArrayAdapter&lt;String&gt; adapterdep = new ArrayAdapter&lt;String&gt;(SignUpStaff.this, android.R.layout.simple_list_item_1, dataofdropdowndep);
              adapterdep.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
              dropstaffdep.setAdapter(adapterdep);
          }
      }
  </code></pre>