您可以先解析字符串:
var temp = JArray.Parse(json);temp.Descendants() .OfType<JProperty>() .Where(attr => attr.Name.StartsWith("_umb_")) .ToList() // you should call ToList because you're about to changing the result, which is not possible if it is IEnumerable .ForEach(attr => attr.Remove()); // removing unwanted attributesjson = temp.ToString(); // backing result to json更新 或:
result.Properties() .Where(attr => attr.Name.StartsWith("_umb_")) .ToList() .ForEach(attr => attr.Remove());更新#2
您可以在
where子句中指定更多条件:
.Where(attr => attr.Name.StartsWith("_umb_") && some_other_condition)要么
.Where(attr => attr.Name.StartsWith("_umb_") || some_other_condition)或任何您需要的。



