title: Retrieving JSON in android with single line object structure
body: <p>I'm quite new to <em>JSON</em> and it's operation I was trying to retrieve <em>JSON</em> from server </p>
  
  <pre><code> datafromServer = bufferedReader.readLine();
                  inputStream.close();
  JSONArray jsonArray = new JSONArray(datafromServer );
  </code></pre>
  
  <p>and came accross to this exception :</p>
  
  <blockquote>
    <p>org.json.JSONException: Value
    {"last_name":"Hicks","id":18,"email":"dwaynehicks@usssulaco.com","first_name":"Dwayne"}
    of type org.json.JSONObject cannot be converted to JSONArray</p>
  </blockquote>
  
  <p>So  I found <a href="https://stackoverflow.com/questions/12722468/org-json-jsonobject-cannot-be-converted-to-jsonarray-in-android"><strong>this</strong></a> answer  :</p>
  
  <pre><code>JSONObject object = new JSONObject(result);
  JSONArray Jarray = object.getJSONArray("contacts");
  
  for (int i = 0; i &lt; Jarray.length(); i++) {
     JSONObject Jasonobject = Jarray.getJSONObject(i);
  </code></pre>
  
  <p>Now, the problem is, in the answer, OP had object formation of :</p>
  
  <pre><code> "contacts": [{
          .....
          .....
  
           ]
  </code></pre>
  
  <p>in this JSON. While I get formation of (<em>no key</em> mapped to this line) :</p>
  
  <pre><code>{"last_name":"Hicks","id":18,"email":"dwaynehicks@usssulaco.com","first_name":"Dwayne"}
  </code></pre>
  
  <p>So how  I modified this line <code>*JSONArray Jarray = object.getJSONArray("contacts");*</code>?
  I don't have such key.</p>
  
  <p>Thanks</p>