I have a class named Order which contains one string list below
Set<String> items;
and when I convert this to JSON:
ObjectMapper mapperObj = new ObjectMapper();
String JSON = mapperObj.writeValueAsString(order);
System.out.println(JSON);
... I get output like below
"items":[
"xyz",
"aaa"
]
I'm looking for an output something like below
"items":[
{
"result":"xyz"
},
{
"result":"aaa"
}
]
I don't want to create a class separately for a single string.
Orderclass and its serialization/deserialization?ObjectMapper mapperObj = new ObjectMapper(); String JSON = mapperObj.writeValueAsString(order); System.out.println(JSON);