title: How to process Json array in android without square bracket
body: <p>Raw Json Data </p>
  
  <pre><code> [  
     {  
        "worker.1":{  
           "last_share":1443639029,
           "score":"3722204.62578",
           "alive":true,
           "shares":1124332,
           "hashrate":1047253
        },
        "worker.2":{  
           "last_share":1443639029,
           "score":"3794755.69049",
           "alive":true,
           "shares":1069332,
           "hashrate":1012070
        },
        "worker.3":{  
           "last_share":1440778690,
           "score":"0.0",
           "alive":false,
           "shares":0,
           "hashrate":0
        },
        "worker.4":{  
           "last_share":1443638222,
           "score":"940190.67723",
           "alive":true,
           "shares":449932,
           "hashrate":404772
        }
        "worker.nth":{  
           "last_share":1443638222,
           "score":"940190.67723",
           "alive":true,
           "shares":449932,
           "hashrate":404772
        }
     }
  ]
  </code></pre>
  
  <p>From the main question I have been able to narrow down the results and managed to add the Square bracket as well. Now i have a Json Array above so could someone advise me how can i process this Json array. Also note that it can end up being 1000 workers. </p>
  
  <p>Please please help I have been breaking my head for 2 days on this,
  Also note that the actual Json data is complex and 1000's of entries,
  The json data included is just an overview.</p>
  
  <p>Edit: Code that I ma using to process the above Json</p>
  
  <pre><code>try{
                          JSONArray jArray = new JSONArray(jsonObj.getJSONObject("workers"));
                          if(jArray.length() == 0){
                              Log.d("Json Err", "JSON string has no entries");
                              return null;
                          }
                          JSONObject jObject = jArray.getJSONObject(0);
  
                          // To get one specific element:
                          JSONObject worker1 = jObject.getJSONObject("worker.1");
                          JSONObject worker2 = jObject.getJSONObject("worker.2");
  
                          // Iterate over all elements
                          Iterator&lt;?&gt; keys = jObject.keys();
                          while( keys.hasNext() ) {
                              String key = (String)keys.next(); // "worker.1", etc
                              if ( jObject.get(key) instanceof JSONObject ) {
                                  JSONObject entry = jObject.getJSONObject(key);
                                  // Do something with your entry here like:
                                  String score = entry.optString("score", "");
                                  Boolean alive = entry.optBoolean("alive", false);
                                  Integer shares = entry.optInt("shares", 0);
                                  Log.d("Json Success", score );
                              }
                          }
                      } catch (JSONException e){
                          Log.e("Json Err", "Failure converting JSON String", e);
                      }
  </code></pre>
  
  <p>Error that I am getting:</p>
  
  <blockquote>
    <p>E2570 (5:10 PM):
        org.json.JSONException: Value {"worker.1":{"last_share":1443694390,"score":"15.6018529132","alive":true,"shares":59880,"hashrate":0},"worker.2":{"last_share":1443694180,"score":"2.97304689833","alive":true,"shares":2048,"hashrate":0},"worker.3":{"last_share":1440778690,"score":"0.0","alive":false,"shares":0,"hashrate":0},"ivonme.ant4":{"last_share":1443701343,"score":"8688.78118933","alive":true,"shares":203088,"hashrate":78633}}
    of type org.json.JSONObject cannot be converted to JSONArray
                at org.json.JSON.typeMismatch(JSON.java)
                at org.json.JSONArray.(JSONArray.java)
                at org.json.JSONArray.(JSONArray.java)</p>
  </blockquote>