title: JSON to hashmap (Jackson)
body: <p>I want to convert JSON to a HashMap with <a href="http://jackson.codehaus.org/" rel="nofollow">Jackson</a>. This is my JSON:</p>
  
  <pre><code>String json = "[{\"Opleidingen\":[{\"name\":\"Bijz. trajecten zorg en welzijn\",\"afk\":\"BTZW\",\"id\":\"0\"},{\"name\":\"Bouwkunde\",\"afk\":\"Bwk\",\"id\":\"14\"},{\"name\":\"Electrotechniek / mechatronica\",\"afk\":\"EltMe\",\"id\":\"15\"},{\"name\":\"Extern\",\"afk\":\"Extern\",\"id\":\"16\"},{\"name\":\"Gezondheidszorg\",\"afk\":\"Zorg\",\"id\":\"17\"},{\"name\":\"Handel\",\"afk\":\"Hand\",\"id\":\"18\"},{\"name\":\"Horeca\",\"afk\":\"Hor\",\"id\":\"19\"},{\"name\":\"Ict\",\"afk\":\"ICT\",\"id\":\"20\"},{\"name\":\"Maatschappelijke zorg\",\"afk\":\"MZ\",\"id\":\"21\"},{\"name\":\"Onderwijs assistent / pedagogisch werk\",\"afk\":\"OAPW\",\"id\":\"22\"},{\"name\":\"Tab / brug\",\"afk\":\"TAB\",\"id\":\"23\"},{\"name\":\"Werktuigbouw / maritieme techniek\",\"afk\":\"WtbMt\",\"id\":\"24\"},{\"name\":\"Zakelijke dienstverlening\",\"afk\":\"TAB\",\"id\":\"25\"}]},{\"Klassen\":[{\"name\":\"V2ZWA\",\"cat\":\"BTZW\",\"id\":\"1\"},{\"name\":\"V2ZWB\",\"cat\":\"Bwk\",\"id\":\"2\"},{\"name\":\"V2ZWB\",\"cat\":\"BTZW\",\"id\":\"3\"},{\"name\":\"V3B2A\",\"cat\":\"BTZW\",\"id\":\"3\"},{\"name\":\"V3B2B\",\"cat\":\"BTZW\",\"id\":\"4\"},{\"name\":\"V3B2C\",\"cat\":\"BTZW\",\"id\":\"5\"},{\"name\":\"V3B2D\",\"cat\":\"BTZW\",\"id\":\"6\"},{\"name\":\"V3B2E\",\"cat\":\"BTZW\",\"id\":\"7\"},{\"name\":\"V3B3A\",\"cat\":\"BTZW\",\"id\":\"8\"},{\"name\":\"V3B3B\",\"cat\":\"BTZW\",\"id\":\"9\"},{\"name\":\"V3B3C\",\"cat\":\"BTZW\",\"id\":\"10\"},{\"name\":\"VWA\",\"cat\":\"BTZW\",\"id\":\"11\"},{\"name\":\"VWB\",\"cat\":\"BTZW\",\"id\":\"12\"},{\"name\":\"VWC\",\"cat\":\"BTZW\",\"id\":\"13\"}]}]"; 
  </code></pre>
  
  <p>I want that I fill in the ID that I get the name back, so: <code>result.get("13");</code> returns <code>VWC</code> and <code>result.get("0");</code> returns <code>Bijz. trajecten zorg en welzijn</code>.</p>
  
  <p>I've tried this:</p>
  
  <pre><code>try {
      @SuppressWarnings("unchecked")
      ArrayList&lt;LinkedHashMap&lt;?, ?&gt;&gt; result = new ObjectMapper().readValue(json, ArrayList.class);
      System.out.println(result.get(1).get("id"));
  } catch (JsonParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  } catch (JsonMappingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  </code></pre>
  
  <p>But then this is the content of <code>result.get(1);</code>:</p>
  
  <pre><code>I/System.out(809): {Klassen=[{name=V2ZWA, cat=BTZW, id=1}, {name=V2ZWB, cat=Bwk, id=2}, {name=V2ZWB, cat=BTZW, id=3}, {name=V3B2A, cat=BTZW, id=3}, {name=V3B2B, cat=BTZW, id=4}, {name=V3B2C, cat=BTZW, id=5}, {name=V3B2D, cat=BTZW, id=6}, {name=V3B2E, cat=BTZW, id=7}, {name=V3B3A, cat=BTZW, id=8}, {name=V3B3B, cat=BTZW, id=9}, {name=V3B3C, cat=BTZW, id=10}, {name=VWA, cat=BTZW, id=11}, {name=VWB, cat=BTZW, id=12}, {name=VWC, cat=BTZW, id=13}]}
  </code></pre>
  
  <p>Also I've tried it without Jackson:</p>
  
  <pre><code>for (int i = 0; i &lt; jObject.length(); i++) {
         JSONArray opleidingen = jObject.getJSONObject(i).getJSONArray("Opleidingen");
         for (int i2 = 0; i2 &lt; opleidingen.length(); i2++) {
             outMap.put(opleidingen.getJSONObject(i2).getString("id"), opleidingen.getJSONObject(i2).getString("name"));
         }
         JSONArray klassen = jObject.getJSONObject(i).getJSONArray("Klassen");
         for (int i3 = 0; i3 &lt; klassen.length(); i3++) {
             outMap.put(klassen.getJSONObject(i3).getString("id"), klassen.getJSONObject(i3).getString("name"));
         }
  }
  </code></pre>
  
  <p>But that is neither working.</p>
  
  <p>Is it possible to convert my JSON to a HashMap (and when ID is given that it returns the name)?</p>
  
  <p>(ArrayList class can be found <a href="http://pastebin.com/6yxnD2tY" rel="nofollow">here</a>)</p>