title: How to extract json string objects separately with Gson
body: <p>I have the following json string: </p>
  
  <pre><code>String config = "{contact:{\"FIRSTNAME\":\"C_FirstName\",\"EMAIL\":\"C_EmailAddress\"}, "
                            + "customobject:{\"CUSTOM_FIELD1\":\"Custom_Field__11\","
                            + "\"FIRSTNAME\":\"First_Name1\",\"EMAIL\":\"Email_Address1\"}}";
  </code></pre>
  
  <p>I need to extract each object, i.e., <code>contact</code> and <code>customobject</code> as a <code>String</code> so the final result should be: </p>
  
  <pre><code>String contact = "{\"FIRSTNAME\":\"C_FirstName\",\"EMAIL\":\"C_EmailAddress\"}";
  String customobject = "{\"CUSTOM_FIELD1\":\"Custom_Field__11\","
                        + "\"FIRSTNAME\":\"First_Name1\",\"EMAIL\":\"Email_Address1\"}";
  </code></pre>
  
  <p>It is required to use <code>Gson</code> for this so I'm trying the following: </p>
  
  <pre><code>Map&lt;String, String&gt; map = gson.fromJson(config, new TypeToken&lt;Map&lt;String,Object&gt;&gt;(){}.getType());
  
   String json = map.get("contact").toString();
  </code></pre>
  
  <p>But I get the following error: </p>
  
  <blockquote>
    <p>java.lang.ClassCastException: com.google.gson.internal.StringMap
    cannot be cast to java.lang.String</p>
  </blockquote>
  
  <p>What is the proper way to achieve this ? </p>