How to turn on indentation when writing JSON using Json.net?
Set the JSON writer Formatting
property to Formatting.Indented
:
jsonWriter.Formatting = Formatting.Indented;
The JsonConvert.Serialize*
methods also have overloads that take a Formatting
enum (thanks John Flatness).
Documentation: Serialize an Object