title: How to deserialize this JSON in an elegant way using flexjson
body: <p>I am working with Oracle OPAM and it has a REST API that has methods like this</p>
  
  <pre><code>{
     "Target Collection":[
        {
       "target":{
          "uri":"https:\/\/opam_server_host:opam_ssl_port\/opam\/target\
  
             /9bbcbbb087174ad1900ea691a2573b61",
          "type":"ldap",
          "name":"person1-ldap",
          "host":"opam_server_host",
          "domain":"berkeley"
          "description" : "Ldap target"
       }
        },
        {
       "target":{
          "uri":"https:\/\/opam_server_host:opam_ssl_port\/opam\/target\
  
             /ac246a162ce948c7b1cdcc17dfc92c15",
          "type":"ldap",
          "name":"person1-ldap2",
          "host":"opam_server_host:opam_ssl_port",
          "domain":"berkeley"
          "description" : "Ldap target"
       }
        }
     ]
  }
  </code></pre>
  
  <p>I am using FlexJSON to deserialize these entities. If I could, I'd use Apache CXF to generate the beans for me, but the problem is that the WADL is under an invalid https certificate + basic authentication, and getting wadl2java to work under these conditions are taking more time than I'd like to spend (too bad it isn't WSDL, so I could just create the stubs from inside eclipse fast and easy).</p>
  
  <p>So I am using this cumbersome approach with flexjson to parse this REST API </p>
  
  <pre><code>JSONDeserializer&lt;Map&lt;String,List&lt;Map&lt;String,Map&lt;String,String&gt;&gt;&gt;&gt;&gt; json = new JSONDeserializer&lt;&gt;();
  Map&lt;String,List&lt;Map&lt;String,Map&lt;String,String&gt;&gt;&gt;&gt; targetCollection = json.deserialize(new InputStreamReader(content));
  List&lt;Map&lt;String,Map&lt;String,String&gt;&gt;&gt; col = targetCollection.get("Target Collection");             Map&lt;String,Map&lt;String,String&gt;&gt; keyVal = col.get(0);
  Map&lt;String,String&gt; targetVal = keyVal.get("target");
  System.out.println(targetVal);
  </code></pre>
  
  <p>This obviously works, but it has so many brackets that reminds me LISP.</p>
  
  <p>It would be so much better if we could just use POJOs instead (even better if I could have then generated automatically by some GUI tool, but I know I am asking too much, we're living in 2014).</p>
  
  <p>I know there is some documentation about how to map attributes here : <a href="http://flexjson.sourceforge.net/#Deserialization" rel="nofollow noreferrer">http://flexjson.sourceforge.net/#Deserialization</a> but I really wish they have some real complex sample (including the JSON - what's the use of explaining how to deserialize without any JSON example in the documentation?)</p>
  
  <p>This question is obviously not new, but it seems that related questions like <a href="https://stackoverflow.com/questions/13843270/how-can-i-deserialize-part-of-a-json-string-into-an-object-using-flexjson">1</a>, <a href="https://stackoverflow.com/questions/14523831/deserializing-a-many-to-one-relation-with-flexjson">2</a> or <a href="https://stackoverflow.com/questions/7792156/flexjson-deserialization-with-custom-objectfactories">3</a> are also waiting for an answer.</p>
  
  <p>(P.S. except <a href="https://stackoverflow.com/questions/11940975/deserializing-json-list-into-list-of-objects-with-flexjson">this</a> one  seems to have some info I can use)</p>
  
  <p>So my question is: <strong>how do I parse this JSON with FlexJSON into a structure not only made of Maps?</strong></p>