public PrettyPrint ( StringBuilder input, StringBuilder output ) : void | ||
input | StringBuilder | |
output | StringBuilder | |
return | void |
public static string PrettifyJson(string json) { var pp = new JsonPrettyPrinter(); var sb_ugly = new StringBuilder(json); var sb_pretty = new StringBuilder(); pp.PrettyPrint(sb_ugly, sb_pretty); return(sb_pretty.ToString()); }
public static string Serialize(Object target, bool prettyPrint) { StringBuilder sbSerialized = new StringBuilder(); JavaScriptSerializer js = new JavaScriptSerializer(); js.Serialize(target, sbSerialized); if (prettyPrint) { StringBuilder prettyPrintedResult = new StringBuilder(); prettyPrintedResult.EnsureCapacity(sbSerialized.Length); JsonPrettyPrinter pp = new JsonPrettyPrinter(); pp.PrettyPrint(sbSerialized, prettyPrintedResult); return prettyPrintedResult.ToString(); } else return sbSerialized.ToString(); }
public static string Serialize(Object target, bool prettyPrint) { StringBuilder sbSerialized = new StringBuilder(); JavaScriptSerializer js = new JavaScriptSerializer(); js.Serialize(target, sbSerialized); if (prettyPrint) { StringBuilder prettyPrintedResult = new StringBuilder(); prettyPrintedResult.EnsureCapacity(sbSerialized.Length); JsonPrettyPrinter pp = new JsonPrettyPrinter(); pp.PrettyPrint(sbSerialized, prettyPrintedResult); return(prettyPrintedResult.ToString()); } else { return(sbSerialized.ToString()); } }