I want to map an object to json to look like this:
{"MyClass" :
[
{"key" : "value"},
{"key" : "value"}
]}
However my code is giving me:
{"MyClass" : {
"list" : {
"key" : "value",
"key" : "value"
}
And my code is like this:
public class MyClass {
private List<Map<String,String>> list;
//getters & setters......
}
And:
Map<String, String> map1 = new HashMap<String,String>();
map1.put("key", "value");
Map<String,String> map2 = new HashMap<String,String>();
map2.put("key","value");
List<Map<String,String> list = new ArrayList<Map<String,String>();
list.add(map1);
list.add(map2);
And I am using ObjectMapper to map the values. What can I do to get the layout I want?
@JsonPropertynotation as my example below