How to convert or cast hashmap to JSON object in Java, and again convert JSON object to JSON string?
Better be late than never. I used GSON to convert list of HashMap to string if in case you want to have a serialized list.
List> list = new ArrayList<>();
HashMap hashMap = new HashMap<>();
hashMap.add("key", "value");
hashMap.add("key", "value");
hashMap.add("key", "value");
list.add(hashMap);
String json = new Gson().toJson(list);
This json produces [{"key":"value","key":"value","key":"value"}]