diff --git a/Wox.Infrastructure/Helper.cs b/Wox.Infrastructure/Helper.cs index 1c94daa281..6d0b30f5de 100644 --- a/Wox.Infrastructure/Helper.cs +++ b/Wox.Infrastructure/Helper.cs @@ -1,5 +1,7 @@ using System; using System.IO; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; namespace Wox.Infrastructure { @@ -63,5 +65,15 @@ namespace Wox.Infrastructure Directory.CreateDirectory(path); } } + + public static string Formatted(this T t) + { + var formatted = JsonConvert.SerializeObject( + t, + Formatting.Indented, + new StringEnumConverter() + ); + return formatted; + } } }