如何删除json文件中所有值为'N/A'
、'-'
或''
的键,例如:
{
"name": {
"first": "Robert",
"middle": "",
"last": "Smith"
},
"age": 25,
"DOB": "-",
"hobbies": [
"running",
"coding",
"-"
],
"education": {
"highschool": "N/A",
"college": "Yale"
}
}
在这种情况下,需要删除middle
和highschool
我试着用这个:
var json = JObject.Parse(jsonString);
json.SelectTokens("@==''").FirstOrDefault().Remove();
1条答案
按热度按时间y0u0uwnf1#
您可以尝试以下代码: