Not sure about the best way to get this List in below format. Please suggest better way to get this format in Java. And also below list is dynamic. Sometimes the values can go up to 10 or more
List<String> list = Arrays.asList("ABC", "DEF", "GHI");
Now we want the above list to be printed as below -
[{"key" : "ABC"}, {"key" : "DEF"}, {"key" : "GHI"}]
I tried to use MultiMap like below
Multimap<String, String> multimap = ArrayListMultimap.create();
multimap.put("key", "ABC");
multimap.put("key", "DEF");
multimap.put("key", "GHI");
Which prints values like
{key=[ABC, DEF, GHI]}