title: Convert Java Map to Javascript Map
body: <p>I have a Java Map. I want to convert it in to JavaScript map.</p>
  
  <p>The java function to convert as JS map follows:</p>
  
  <pre><code>private Object getJSLocalizedValueMap() {
  
      Map&lt;String, String&gt; langSel = new HashMap&lt;String, String&gt;();
      langSel.add("en", true);
      langSel.add("de", false);
      langSel.add("fr", false);
  
      //Now convert this map into Javascript Map
      NativeObject nobj = new NativeObject();
      ScriptEngineManager factory = new ScriptEngineManager();
      ScriptEngine engine = factory.getEngineByName("javascript");
      for (Map.Entry&lt;String, String&gt; entry : langSel.entrySet()) {
          nobj.defineProperty(entry.getKey(), entry.getValue(), NativeObject.READONLY);
      }
      engine.put("langSel", nobj);
      return langSel;
  }
  </code></pre>
  
  <p>In the JSP page's javascript the code is:</p>
  
  <pre><code>var langs = ${messagesJS};
  </code></pre>
  
  <p>In Javascript, I got:</p>
  
  <pre><code>langs = {en=true, de=false, fr=false};
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>langs = {"en":true, "de":false, "fr":false}
  </code></pre>
  
  <p>Please suggest me how to achieve this?</p>