Problems with Json Serialize Dictionary

后端 未结 5 2486
自闭症患者
自闭症患者 2021-02-19 16:55

whenever i try to serialize the dictionary i get the exception:

System.ArgumentException: Type 
\'System.Collections.Generic.Dictionary`2[[Foo.DictionarySerializ         


        
5条回答
  •  别跟我提以往
    2021-02-19 17:30

    Exception says "keys must be strings or object" so try

    data.Add(Enum.ToObject(typeof(TestEnum), TestEnum.A));
    data.Add(Enum.ToObject(typeof(TestEnum), TestEnum.B));
    data.Add(Enum.ToObject(typeof(TestEnum), TestEnum.C));
    

    I did not test it though, just a guess.

提交回复
热议问题