Why serializing Version with JsonPropertyAttribute doesn't work?

前端 未结 1 471
逝去的感伤
逝去的感伤 2020-12-12 04:58

I am trying to serialize an object with a static System.Version field:

[JsonObject(MemberSerialization.OptIn)]
public class MyObj
{
    [JsonPro         


        
1条回答
  •  情话喂你
    2020-12-12 05:06

    ItemConverterType allows you to specify a converter to use for collection items. See Proper way of using Newtonsoft Json ItemConverterType. Since string and Version aren't treated as collections, it's ignored. For a converter on the property itself use [JsonConverter].

    Conversely, if you had a static List versions it would be appropriate to use [JsonProperty(ItemConverterType = typeof(VersionConverter))].

    0 讨论(0)
提交回复
热议问题