I want to convert Map<String,String>
to Custom Json output e.g:
My Map have data like
--------
ID |Desc
--------
1 | A
2 | B
3 | C
My Json should out put above map with custom keys i.e. ID & Desc:
[{id:1,desc,A},{id:2,desc,B},{id:3,desc,C}]
Earlier I have used List to convert to Json using object classes:
List<CustomObject> myList = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
String jsonText = mapper.writeValueAsString(myList);
so this converts to what ever fields i have in CustomObject Class. But as Map just have key/values and no fieldnames, so i need to know how i can set them.