Problems with Json Serialize Dictionary

后端 未结 5 2472
自闭症患者
自闭症患者 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:24

    Use Newtonsoft (Newtonsoft.Json.dll) to serialize the Dictionary object and you'd be fine. It's a popular third party library you would have to download and include in your project as a reference.

    See example below:

    var _validationInfos = new Dictionary();
    var serializedData = JsonConvert.SerializeObject(_validationInfos);
    

提交回复
热议问题