title: Class cast exception [JSONArray cannot be cast to org.json.simple.JSONObject]
body: <p>I have a json file like this</p>
  
  <pre><code>[ {
      "id":"serve-coffee",
      "tags":[ {
          "name": "@tag1", "line": 1
      }
      ],
      "description":"Coffee should not be served\n",
      "name":"Serve coffee",
      "keyword":"Feature",
      "line":2,
      "elements":[ {
          "id": "serve-coffee;buy-last-coffee", "tags":[ {
              "name": "@tag2", "line": 6
          }
          ],
          "description":"",
          "name":"Buy last coffee",
          "keyword":"Scenario",
          "line":7,
          "steps":[ {
              "name": "there are 1 coffees left in the machine", "keyword": "Given ", "line": 8
          }
          ,
          {
              "name": "I have deposited 1$", "keyword": "And ", "line": 9
          }
          ],
          "type":"scenario"
      }
      ],
      "uri":"src\/test\/resources\/traffic-remove-locations.feature"
  }
  
  ]
  </code></pre>
  
  <p>Iam trying to convert the above json file to <code>JSONObject</code>.But am getting class cast exception <code>"java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.simple.JSONObject"</code></p>
  
  <p>code</p>
  
  <pre><code>public static JSONObject convertFileToJSON(String fileName) throws ParseException {
  
          // Read from File to String
          JSONParser parser = new JSONParser();
          JSONObject jsonObject = null;
          try {
              Object object = parser.parse(new FileReader(fileName));         
              jsonObject = (JSONObject) object;   // Getting classCast Exception here.
  
          } catch (FileNotFoundException e) {
  
          } catch (IOException ioe) {
  
          }       
          return jsonObject;
      }
  </code></pre>
  
  <p><code>but when i changed the line</code> <code>jsonObject = (JSONObject) object;</code> <code>to</code> <code>JSONArray jsonArray = (JSONObject)object</code> the exception disappears.
      But if am casting to <code>JSONArray</code> then how can i get the values like <code>id,tags</code> and <code>description</code> from <code>JSONArray</code>. 
      please provide a suggestion guys</p>