Пример #1
0
    public static void Main(string[] args)
    {
        var x = new Example();

        x.Property1 = "string1";
        x.field1    = "field1string";
        x.Address   = new PostalAddress("main st.", 12346);
        x.IntList   = new List <int>()
        {
            1, 2, 3
        };
        x.Addresses = new List <PostalAddress>()
        {
            new PostalAddress("side st", 12345),
        };
        x.Dict = new Dictionary <string, int>()
        {
            { "this", 1 },
            { "that", 2 },
        };

        Console.WriteLine(SimpleJson.ToJson(x));
        Console.WriteLine(SimpleJson.ToJson(123));
        Console.WriteLine(SimpleJson.ToJson(123.456));
        Console.WriteLine(SimpleJson.ToJson("string"));
        Console.WriteLine(SimpleJson.ToJson("string\"\\"));
        Console.WriteLine(SimpleJson.ToJson("string\u0012"));
        Console.WriteLine(SimpleJson.ToJson(true));
        Console.WriteLine(SimpleJson.ToJson(false));
        Console.WriteLine(SimpleJson.ToJson(null));
        Console.WriteLine(SimpleJson.ToJson('c'));
        Console.WriteLine(SimpleJson.ToJson('\\'));
        Console.WriteLine(SimpleJson.ToJson('"'));
        Console.WriteLine(SimpleJson.ToJson('\u0012'));
    }