Q:

Accessing key-value pairs of Java Map in javascript

I have a Map<String, String> in back-end which is sent to front-end javascript as Map. I need to get all key-value pairs and display it in UI. For doing this, I have tried like,
org.JSON.JSONObject js = new org.JSON.JSONObject(Map);

But it does not work. Is there any way to handle Java map in javascript?

A:

You can try something like using ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper;),
  String jsString =  new ObjectMapper().writeValueAsString(Map<String,String>)

Then you can create jsonObject as,
JSONObject js = new JSONObject(jsString);

