コード例 #1
0
ファイル: Json.Object.cs プロジェクト: avaranovich/xenogears
        private void Object_BuildPrettyString(IndentedWriter writer)
        {
            writer.Write("{");
            writer.Indent++;

            var keys = Keys.AssertCast <String>();

            if (keys.IsNotEmpty())
            {
                keys.ForEach((key, i) =>
                {
                    writer.WriteLine();
                    writer.Write("\"{0}\" : ", key);
                    if (((IEnumerable)this[key].Keys).Cast <Object>().Count() > 0)
                    {
                        writer.WriteLine();
                    }
                    this[key].BuildPrettyString(writer);
                    if (i < this.Count() - 1)
                    {
                        writer.Write(",");
                    }
                });

                writer.WriteLine();
            }

            writer.Indent--;
            writer.Write("}");
        }
コード例 #2
0
        private void Array_BuildPrettyString(IndentedWriter writer)
        {
            writer.Write("[");
            writer.Indent++;

            var keys = Keys.AssertCast <int>();

            if (keys.IsNotEmpty())
            {
                keys.ForEach((key, i) =>
                {
                    (key == i).AssertTrue();
                    // todo. omg what's with these dynamic invocations?!
                    if (((IEnumerable)this[key].Keys).Cast <Object>().Count() > 0)
                    {
                        writer.WriteLine();
                    }
                    this[key].BuildPrettyString(writer);
                    if (i < this.Count() - 1)
                    {
                        writer.Write(",");
                    }
                });

                writer.WriteLine();
            }

            writer.Indent--;
            writer.Write("]");
        }
コード例 #3
0
ファイル: Json.Object.cs プロジェクト: avaranovich/xenogears
        private void Object_BuildCompactString(TextWriter writer)
        {
            var keys = Keys.AssertCast <String>();

            writer.Write(String.Format("{{{0}}}", keys.Select((key, i) =>
            {
                return(String.Format("\"{0}\":{1}", key, this[key].ToCompactString()));
            }).StringJoin(",")));
        }
コード例 #4
0
        private void Array_BuildCompactString(TextWriter writer)
        {
            var keys = Keys.AssertCast <int>();

            writer.Write(String.Format("[{0}]", keys.Select((key, i) =>
            {
                (key == i).AssertTrue();
                return(this[key].ToCompactString());
            }).StringJoin(",")));
        }