title: How to make a JSON String using the key/value from the Map
body: <p>I am trying to create a JSON String using the corresponding key/value pair. In the below code, I am trying to iterate the list of <code>AttributeValue</code> and then I am trying to makie the JSON String using the <code>al.getValue map</code>.</p>
  
  <pre><code>private &lt;T&gt; String createJsonWithEscCharacters(List&lt;AttributeValue&lt;T&gt;&gt; list) {
  
      StringBuilder keyValue = new StringBuilder();
  
      if (list != null) {
          for (AttributeValue&lt;?&gt; al: list) {
  
              keyValue.append("\"").append("v").append("\"").append(":").append(" {");
  
              for (Map.Entry&lt;String, String&gt; entry : ((Map&lt;String, String&gt;) al.getValue()).entrySet()) {
                  keyValue.append("\"").append(entry.getKey()).append("\"");
                  keyValue.append(":").append(" \"").append(entry.getValue()).append("\"").append(",");
                  System.out.println(keyValue);
              }
  
          }
      }
  
      return null;
  }
  </code></pre>
  
  <p>When I inspect on <code>al</code>, I see <code>value</code> as <code>LinkedHashMap&lt;K,V&gt;</code> and when I print <code>al.getValue()</code>, it gives me this-</p>
  
  <pre><code>{predictedCatRev=0;101;1,1;201;2, predictedOvrallRev=77;2,0;1,16;3, sitePrftblty=77;2,0;1671679, topByrGms=12345.67, usrCurncy=1, vbsTopByrGmb=167167.67}
  </code></pre>
  
  <p>So that means, I can iterate the <code>al.getValue()</code> map and use those <code>key/value pair</code> to make the JSON String.</p>
  
  <p>Now I am trying to make a JSON String by iterating the <code>al.getValue()</code> map. So the JSON String should look something like this after iterating the <code>al.getValue()</code> map-</p>
  
  <pre><code>{
   "lv": [
    {
     "v": {
      "predictedCatRev": "0;101;1,1;201;2",
      "predictedOvrallRev": "77;2,0;1,16;3",
      "sitePrftblty": "77;2,0;1671679",
      "topByrGms": "12345.67",
      "usrCurncy": "1",
      "vbsTopByrGmb": "167167.67"
     }
    }
   ],
  }
  </code></pre>
  
  <p>I am wondering what is the cleanest way to do this? In my above code, I am not fully able to make the above JSON String but whatever code I have above, it is able to make slight portion of JSON String in the way I needed but the not full JSON String in the way, I am looking for. Can anyone help me on this like what will be the cleanest way to do this?</p>
  
  <p>Thanks</p>