PrettyPrint() 공개 메소드

public PrettyPrint ( StringBuilder input, StringBuilder output ) : void
input StringBuilder
output StringBuilder
리턴 void
예제 #1
0
        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());
        }
예제 #2
0
        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();
        }
예제 #3
0
        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());
            }
        }