How can I get the following JSON response to look cleaner using MVC 4 API. This is a sample JSON
{"Name":"Apple","Expiry":"2008-12-28T00:00:00","Price":3.99}
Pretty JSON
{
"Name":"Apple",
"Expiry":"2008-12-28T00:00:00",
"Price":3.99
}
You can do this using Json.net NuGet package:
JObject.Parse(json).ToString(Formatting.Indented)
If you're using the Web Api. You can set:
var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With