title: convert a json object response into array and get both key and value android
body: <p>I have a json response which is dynamic such that even the key name and index no.can change</p>
  
  <pre><code>{
  "Assigned": {
      "DC": 7,
      "EmpCode": "E0104",
      "FS": 8
  }
  }
  </code></pre>
  
  <p>I want to convert it into JsonArray and fetch all the key names and values dynamically under the object 'Assigned'.But I am only getting the value name by trying this.</p>
  
  <pre><code>try {
                          //converting dynamic jsonobject to json array and fetching value as well as key name
                          JSONObject jsonObject = response.getJSONObject("Assigned");
                          Iterator x = jsonObject.keys();
                          JSONArray jsonArray = new JSONArray();
                          while (x.hasNext()) {
                              String key = (String) x.next();
                              jsonArray.put(jsonObject.get(key));
                      }
                          Toast.makeText(RolesActivity.this,jsonArray.toString(), Toast.LENGTH_LONG).show();
                          Log.d("jsonarray",jsonArray.toString());
  
                      }
                      catch (Exception e)
                      {
                          e.printStackTrace();
                          Toast.makeText(RolesActivity.this, e.toString(), Toast.LENGTH_SHORT).show();
                      }
  </code></pre>