SharePoint WCF-Services JSON DateTime格式在C#中解析

发布于 2025-01-22 17:00:18 字数 341 浏览 2 评论 0原文

我正在尝试通过较旧的_vti_bin/client.svc端点从SharePoint API读取一些数据,

我似乎找不到这是什么类型的日期格式,以及如何通过C#解析它。

返回的时间戳是:

"LastContentModifiedDate": "/Date(2022,3,18,13,12,28,990)/"

年度和月很明显,因此,如果我知道所有的价值观,我可以自己解析。是否有正式的定义或一种可靠地解析此方法的方法?这是DateTime或DateTimeOffset还是其他?

试图在DateTime或DateTimeOffset中脱口而出时,我只是得到了例外。

I am trying to read some data from the SharePoint API via the older _vti_bin/client.svc endpoint

I can't seem to find what type of date format this is and how I can parse it via C#.

The timestamp being returned is:

"LastContentModifiedDate": "/Date(2022,3,18,13,12,28,990)/"

The year and month are obvious so I could parse it myself if I knew what all the values are. Is there a formal definition for this or a way to parse this reliably? Is this a DateTime or DateTimeOffset or something else?

I just get an exception when trying to deserialize to a DateTime or DateTimeOffset.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就此别过 2025-01-29 17:00:18

/ date(...)/格式是Microsoft的内置JSON日期格式。
您可以尝试使用下面的代码对其进行解析。
您也可以查看这篇文章,提供了许多方法。

using System.Web.Script.Serialization;    
//code
JavaScriptSerializer json_serializer = new JavaScriptSerializer();
DateTime ddate = json_serializer.Deserialize<DateTime>(@"""\/Date(1326038400000)\/""").ToLocalTime();

The /Date(...)/ format is Microsoft's built-in JSON date format.
You can try to parse it using the code below.
You can also check out this post, which provides a lot of methods.

using System.Web.Script.Serialization;    
//code
JavaScriptSerializer json_serializer = new JavaScriptSerializer();
DateTime ddate = json_serializer.Deserialize<DateTime>(@"""\/Date(1326038400000)\/""").ToLocalTime();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文