title: Decode JSON string in Java with json-simple library
body: <p>I am new to using the json-simple library in Java and I've been through both the <a href="https://code.google.com/p/json-simple/wiki/EncodingExamples" rel="noreferrer">encoding</a> and <a href="https://code.google.com/p/json-simple/wiki/DecodingExamples" rel="noreferrer">decoding</a> samples. Duplicating the encoding examples was fine, but I have not been able to get the decoding ones to work with mixed type JSON.</p>
  
  <p>One of my problems is that there are too many classes in the library which are not properly documented, and for which I do not have the source (in order to be able to read through and understand their purpose). Consequently, I am struggling to understand how to use a lot of these classes.</p>
  
  <p>After reading this example:</p>
  
  <pre><code>String jsonText = "{\"first\": 123, \"second\": [4, 5, 6], \"third\": 789}";
  JSONParser parser = new JSONParser();
  
  ContainerFactory containerFactory = new ContainerFactory(){
      public List creatArrayContainer() {
          return new LinkedList();
      }
  
      public Map createObjectContainer() {
          return new LinkedHashMap();
      }                     
  };
  
  try {
      Map json = (Map)parser.parse(jsonText, containerFactory);
      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("==toJSONString()==");
      System.out.println(JSONValue.toJSONString(json));
  } catch(ParseException pe) {
      System.out.println(pe);
  }
  </code></pre>
  
  <p>from the <a href="https://code.google.com/p/json-simple/wiki/DecodingExamples" rel="noreferrer">json-simple official decoding tutorial</a>, I tried to decode this JSON:</p>
  
  <pre><code>{
  "stat":{
      "sdr": "MAC address of FLYPORT",
      "rcv": "ff:ff:ff:ff:ff:ff",
      "time": "0000000000000",
      "type": 0,
      "subt": 0,
      "argv": [
          {"type": "6","val": "NetbiosName"},
          {"type": "6","val": "MACaddrFlyport"},
          {"type": "6","val": "FlyportModel"},
          {"type": "1","val": id}
      ]
  }
  }
  </code></pre>
  
  <p>I am writing following code to decode:</p>
  
  <pre><code>    String jsonString = "{\"stat\":{\"sdr\": \"aa:bb:cc:dd:ee:ff\",\"rcv\": \"aa:bb:cc:dd:ee:ff\",\"time\": \"UTC in millis\",\"type\": 1,\"subt\": 1,\"argv\": [{1,2},{2,3}]}}";
      JSONObject jsonObject = new JSONObject(jsonString);
      JSONObject newJSON = jsonObject.getJSONObject("stat");
      System.out.println(newJSON);
  </code></pre>
  
  <p>But it doesn't work. Infact I was not able to get the unmodified example working either, and the original authors have not explained their code.</p>
  
  <p>What is the easiest way to decode this JSON as shown?</p>