【发布时间】:2015-11-06 15:01:51
【问题描述】:
我正在尝试使用 NewtonSoftJSON 在我的 Xamarin 应用程序中将数据集序列化为 JSON,但出现以下错误
从“NativeCalendarName”获取值时出错 关于'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);
}
【问题讨论】:
-
它试图序列化 DateTime、它的属性、它的所有属性,等等。快速解决方案是将属性转换为包含 DateTime 的 UTC 值的字符串,并在数据集上添加一个方法,如果可能,将其转换回 DateTime。
-
可能也想添加你的 json。
-
但是@Will 我的数据集不包含任何日期时间或任何日期时间格式。是否有任何属性会跳过此日期格式检查?
-
也许不是直接的,但是下线有人公开引用了它。顺便说一句,你刚刚得到了一个更好的答案。
-
Ya @Will ,尝试相同。感谢您的帮助
标签: c# json xamarin deserialization