Json.Net PopulateObject Appending list rather than setting value

后端 未结 1 829
执念已碎
执念已碎 2020-12-16 11:22

I am using Json.Net for .Net 4.5 and when using populate object on the following object it increments the List\'s with the content of the json rather than setting its value.

相关标签:
1条回答
  • 2020-12-16 11:46

    You should tell Json.Net to replace the arrays, like this:

    var serializerSettings = new JsonSerializerSettings {ObjectCreationHandling = ObjectCreationHandling.Replace};
    
    
    JsonConvert.PopulateObject(jasonString, myObject, serializerSettings)
    
    0 讨论(0)
提交回复
热议问题