Getting the error “Cannot add or remove items from Newtonsoft.Json.Linq.JProperty” in Json.net

后端 未结 2 1391
礼貌的吻别
礼貌的吻别 2020-12-03 16:43

So I\'m trying to control deserialization by reading a json object as a JObject, deleting some fields, and then deserializing it again to my target object using Json.Net. Th

2条回答
  •  情书的邮戳
    2020-12-03 17:09

    Based on brillian answer from Brian, you can do simply this in your case:

    var inner_id = inner["_id"] as JProperty;
    if (inner_id != null)
      inner_id.Remove();
    

提交回复
热议问题