mgholam / fastJSON

Smallest, fastest polymorphic JSON serializer
https://www.codeproject.com/Articles/159450/fastJSON-Smallest-Fastest-Polymorphic-JSON-Seriali
MIT License
479 stars 147 forks source link

ToObject<Dictionary<string, List<AC>>>(jsonstr) is't work #34

Closed chunlizh closed 7 years ago

chunlizh commented 7 years ago

i having a Class named "AC", then i have define Dictionary<string, List<AC>> AdjustConfig;

public class AC { public AC() { } public decimal Lo { get; set; } public decimal Ratio { get; set; } }

ToObject<Dictionary<string, List>>(jsonstr) is't work

mgholam commented 7 years ago

What is the jsonstr value?

chunlizh commented 7 years ago
    private static void DictListTest()
    {
        fastJSON.JSON.Parameters.UseExtensions = false;
        Dictionary<string, List<AC>> dictList = new Dictionary<string, List<AC>>();
        dictList.Add("P", new List<AC>());
        dictList["P"].Add(new AC() { });
        string jsonstr = fastJSON.JSON.ToJSON(dictList);

        Console.WriteLine();
        Console.WriteLine(jsonstr);

        Dictionary<string, List<AC>> dictList2 = fastJSON.JSON.ToObject<Dictionary<string, List<AC>>>(jsonstr);

        foreach (var k in dictList2)
        {
            Console.Write(k.Key);
            foreach (var v in k.Value)
                Console.WriteLine(":\tLo:{0}\tRatio:{1}", v.Lo, v.Ratio);
        }

    }

if set fastJSON.JSON.Parameters.UseExtensions = false,is't work

mgholam commented 7 years ago

Fixed, will post soon, thanks!