我尝试使用 NewtonSoftJSON 在 Xamarin 应用程序中将数据集序列化为 JSON,但仍出现以下错误
Error getting value from 'NativeCalendarName' on'System.Globalization.DateTimeFormatInfo'.
虽然我没有在数据集中使用任何日期时间,但我遇到了错误。请帮我解决同样的问题。谢谢 到目前为止我已经完成了
string output = JsonConvert.SerializeObject(dsComp, Newtonsoft.Json.Formatting.None,
new Newtonsoft.Json.JsonSerializerSettings()
{
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
});
using(var streamWriter = new System.IO.StreamWriter(filename, true))
{
streamWriter.WriteLine(output);
}
最佳答案
您必须告诉如何序列化日期时间格式。试试这个
string output = JsonConvert.SerializeObject(dsComp, Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
DateFormatHandling = DateFormatHandling.IsoDateFormat
});
关于c# - 牛顿软件 JSON : Error getting value from 'NativeCalendarName' on 'System.Globalization.DateTimeFormatInfo' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33569654/