简体   繁体   English

如何从 json 反序列化 TimeOnly (c#)?

[英]How do I deserialize TimeOnly (c#) from json?

I am currently doing the following:我目前正在执行以下操作:

var json = JsonConvert.SerializeObject(product);
return JsonConvert.DeserializeObject<Dictionary<string, string>>(json);

The object product has objects of type TimeOnly . object product具有TimeOnly类型的对象。 The serialize part works but the deserialize causes it to crash.序列化部分可以工作,但反序列化会导致它崩溃。 Any ideas?有任何想法吗?

Thanks in advance.提前致谢。

https://github.com/JamesNK/Newtonsoft.Json/issues/2521 https://github.com/JamesNK/Newtonsoft.Json/issues/2521

Supported in 13.0.2 betas.在 13.0.2 测试版中受支持。 System.Text.Json supports it. System.Text.Json支持它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM