I started to use Jackson a few days ago and I find this library super powerful, but there is something I couldn't manage to do : write arrays on multiple lines.
I have the following code :
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
public class App {
public static void main(String[] args) {
ObjectMapper mapper = new ObjectMapper();
ArrayNode node = mapper.createArrayNode();
node.add("1");
node.add("2");
node.add("3");
try {
System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(node));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}
With that I get this :
[ "1", "2", "3" ]
But I want this :
[
"1",
"2",
"3"
]
How could I do that ?
Thanks
PS sorry if I did mistakes, English isn't my native language