LitJSON / litjson

JSON library for the .Net framework
https://litjson.net/
Other
1.36k stars 403 forks source link

PrettyPrint is not working so well #10

Open blaubart69 opened 11 years ago

blaubart69 commented 11 years ago

This code ...

using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var wr = new LitJson.JsonWriter(Console.Out);

            wr.PrettyPrint = true;
            wr.WriteArrayStart();

            foreach (KeyValuePair<string, int> kv in 
                new List<KeyValuePair<string, int>> { 
                    new KeyValuePair<string,int>("bumsti",1),
                    new KeyValuePair<string,int>("mausi",2),
                    new KeyValuePair<string,int>("zandi",3) 
                })
            {
                wr.PrettyPrint = true;
                wr.WriteObjectStart();
                wr.PrettyPrint = false;

                wr.WritePropertyName(kv.Key);
                wr.Write(kv.Value);
                wr.WriteObjectEnd();
            }

            wr.PrettyPrint = true;
            wr.WriteArrayEnd();

        }
    }
}

gives me that output:

[
    {"bumsti":1},
        {"mausi":2},
            {"zandi":3}
            ]

want to have...

[
    {"bumsti":1},
    {"mausi":2},
    {"zandi":3}
]