I want to save some json to file
This is my serializtion code:
private String serializeToJson(T item) {
String json;
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
try {
json = ow.writeValueAsString(item);
} catch (IOException e) {
e.printStackTrace();
json = "";
}
return json;
}
and yet my json is save to file not formatted:
e.g. part of it is:
{"path":{"segmentId":69798169,"nodeId":18477384,"x":-71.12074,"y":42.33235},"street":1,"altStreets":null,"distance":59,"length":178,"crossTime":49,"crossTimeWithoutRealTime":49,"tiles":[0,1],"clientIds":[166,177],"instruction":
Tried Jackson pretty print mapper?assumed object has implemented toString method