c# - 牛顿软件 JSON : Error getting value from 'NativeCalendarName' on 'System.Globalization.DateTimeFormatInfo'

标签 c# json xamarin deserialization

我尝试使用 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/

相关文章:

c# - 什么是 ASP.NET 提供程序?

c# - HttpWebRequest 收到 "WebException: The request timed out"

c# - 如何在 WPF 中获取 "Selected MenuItem"

json - 使用 ko.toJSON 进行 knockout 序列化 - 如何忽略 null 属性

android - 如何从 Xamarin 编写 firebase ServerValue.Timestamp

Android 调试器错误 (MonoDroid)

c# - 在 Sitecore 页面编辑器中验证

java - 将 JSON 映射到 Java 对象

json - 从 BigQuery 中的字符串化 JSON 解析时间戳对象

c# - 使用Xamarin Android,如何在任务完成之前显示进度条?