title: json-simple, reading from a file
body: <p>I am trying to iterate through a file in the file system which contains configuration information for numerous devices.</p>
  
  <p>The file is in this format:</p>
  
  <pre><code> {
      "myDevicesInfo":
      [
          {
              "DeviceType":"foo", 
              "DeviceName":"foo1", 
              "IPAddress":"192.168.1.1", 
              "UserName":"admin", 
              "Password":"pw"
          }
      ]
  }
  </code></pre>
  
  <hr>
  
  <p>I am getting the following error when trying to get the inner key-value pairs:</p>
  
  <p><strong>Exception in thread "main" java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.simple.JSONObject
      at mav2bac.loadDevices(bac.java:98)
      at mav2bac.main(bac.java:70)</strong></p>
  
  <pre><code>File appBase = new File("."); //current directory
              String path = appBase.getAbsolutePath();
              System.out.println(path);
  
              Object obj = parser.parse(new FileReader("bac.yml"));
  
              JSONObject jsonObject = (JSONObject) obj;
              JSONObject jsonObjectDevice = (JSONObject)jsonObject;
              JSONObject deviceAttributes = (JSONObject) jsonObject.get("myDevicesInfo");
  
              Map json = (Map)parser.parse(jsonObject.toJSONString(), containerFactory);
              System.out.println(json.values());
              Iterator iter = json.entrySet().iterator();
              System.out.println("==iterate result==");
              while(iter.hasNext()){
                Map.Entry entry = (Map.Entry)iter.next();
                //System.out.println(entry.getKey() + "=&gt;" + entry.getValue());
                System.out.println(entry.getValue());
              }
  </code></pre>
  
  <hr>
  
  <p>So what is the proper way to get convert use ContainerFactory and instantiate an object containing these values?</p>
  
  <hr>