C# Serialize Dictionary to JSON

后端 未结 3 1840
没有蜡笔的小新
没有蜡笔的小新 2021-02-14 08:54

I am trying to serialize a Dictionary to JSON, and get the following exception:

new JavaScriptSerializer().Serialize(mydict)`

Ty

3条回答
  •  醉酒成梦
    2021-02-14 09:36

    use NewtonSoft.Json instead of JavaScriptSerializer to overcome this problem:

    Ex:

    JsonConvert.SerializeObject(mydict);
    

提交回复
热议问题