0

When running on windows I always get "\r\n" in the output, but I was trying to just return "\n"

    ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readTree("{\"key\":\"value\"}")
    .toPrettyString();

Is there a easy way to achieve this?

M4rk
  • 2,172
  • 5
  • 36
  • 70
  • I seem to recall -- and this could be outdated -- that several of the libraries decided to be "helpful" and use the system defined line ending. It might be possible to set the `DefaultIndenter` to a specific line feed. See, perhaps, [Configure line endings](https://github.com/FasterXML/jackson-databind/issues/585). – KevinO Jan 07 '21 at 02:10
  • 1
    call setDefaultPrettyPrinter with an instance of PrettyPrinter that does what you want. – Gabe Sechan Jan 07 '21 at 02:10
  • https://stackoverflow.com/a/14938984/829571 – assylias Jan 07 '21 at 03:49

0 Answers0