When serializing a list of string with Jackson library, it provides correctly a JSON array of strings:
<mapper>.writeValue(System.out, Arrays.asList("a", "b", "c"));
[ "a", "b", "c" ]
However, the strings are wrapped/enclosed by a class in our code:
public static class StringWrapper {
protected final String s;
public String getS() {
return s;
}
public StringWrapper(final String s) {
this.s = s;
}
}
When serializing a list of "string wrapers", I would like to have the same output as above. Now I get:
<mapper>.writeValue(System.out, Arrays.asList(new StringWrapper("a"), new StringWrapper("b"), new StringWrapper("c")));
[ {
"s" : "a"
}, {
"s" : "b"
}, {
"s" : "c"
} ]
What is the most convenient method to do this? If possible, deserializing should work also.