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
More Related Contents:
- How to deserialize an array of values with a fixed schema to a strongly typed data class?
- Detect if deserialized object is missing a field with the JsonConvert class in Json.NET
- Casting interfaces for deserialization in JSON.NET
- How to serialize/deserialize a custom collection with additional properties using Json.Net
- How to tell Json.Net globally to apply the StringEnumConverter to all enums
- Json.NET serialize object with root name
- Custom Deserialization using Json.NET
- How can I serialize/deserialize a dictionary with custom keys using Json.Net?
- JToken: Get raw/original JSON value
- How to call JsonConvert.DeserializeObject and disable a JsonConverter applied to a base type via [JsonConverter]?
- Send JSON via POST in C# and Receive the JSON returned?
- Cannot deserialize JSON array into type – Json.NET
- How to apply indenting serialization only to some properties?
- JSON.net (de)serialize untyped property
- Ignoring null fields in Json.net
- Deserialize json object with dynamic items in C#
- How can I merge two JObject? [duplicate]
- Json.NET adding backslash while returning json serialized string
- Deserializing JSON into an object with Json.NET
- Json.net rename properties
- Newtonsoft JSON for .net is ignoring jsonproperty tags
- parse JSON using json.net c# [closed]
- How to show the “paste Json class” in visual studio 2012 when clicking on Paste Special?
- dotnet core System.Text.Json unescape unicode string
- Newtonsoft Json.Net serialize JObject doesn’t ignore nulls, even with the right settings
- Json.NET custom serialization with JsonConverter – how to get the “default” behavior
- Deserializing heterogenous JSON array into covariant List using Json.NET
- Deserialize specific enum into system.enum in Json.Net
- Serialize/Deserialize dynamic property name using JSON.NET
- Null-coalescing operator returning null for properties of dynamic objects