JsonConvert.DeserializeObject> is returning null objects in List

后端 未结 2 1314
陌清茗
陌清茗 2021-01-24 09:53

I am new to Json.Net and am having a difficult time deserializing my Json objects into .Net objects. It creates ConclusionEntityCategory objects but those in turn contain null o

相关标签:
2条回答
  • 2021-01-24 10:10

    Try marking the internal properties on ConclusionEntityCategory with [JsonProperty] attribute, or if that is not desirable, set DefaultContractResolver.DefaultMemberSearchFlags to include non-public flag.

    0 讨论(0)
  • 2021-01-24 10:16

    As a result of Category, SubCategory1, and SubCategory2 being internal, the serializer cannot set them. These need to be public properties in order to be populated.

    internal class ConclusionEntityCategory
    {
     public string Category { get; set; }
     public string SubCategory1 { get; set; }
     public List<string> SubCategory2 { get; set; }
    }
    
    0 讨论(0)
提交回复
热议问题