Using Json.net - partial custom serialization of a c# object

前端 未结 3 424
萌比男神i
萌比男神i 2020-12-11 02:44

I ma using Newtonsofts\' Json.Net to serialize some and array of objects to json. The objects have a common set of properties but also have Meta property which is a diction

3条回答
  •  爱一瞬间的悲伤
    2020-12-11 02:58

    If your dictionary is a string to object dictionary could can simply use the [JsonExtensionData] attribute:

    [JsonExtensionData]
    public Dictionary Meta { get; set; }
    

    See How to serialize a Dictionary as part of its parent object using Json.Net.

提交回复
热议问题