无法找到正确的答案,所以我想更改问题。
我有一个JSON代码,如下所示:
[
{
"section_id": "58ef93aaa310c97c0c16bcd2",
"name": "Name1",
"slug": "slug1"
},
{
"section_id": "58ef93aaa310c97c0c16bcd3",
"name": "Name2",
"slug": "slug2"
},
{
"section_id": "58ef93aaa310c97c0c16bcd4",
"name": "Name3",
"slug": "slug3",
"categories": [
{
"section_id": "58ef93aaa310c97c0c16bcd5",
"name": "Name31",
"slug": "slug31"
},
{
"section_id": "58ef93aaa310c97c0c16bcd6",
"name": "Name32",
"slug": "slug32",
"categories": [
{
"section_id": "58ef93aaa310c97c0c16bcd7",
"name": "Name321",
"slug": "slug321"
},
{
"section_id": "58ef93aaa310c97c0c16bcd8",
"name": "Name322",
"slug": "slug322"
},
{
"section_id": "58ef93aaa310c97c0c16bcd9",
"name": "Name323",
"slug": "slug323"
}
]
}
]
}
]
我想改变" section_id"的每一次出现。在它之后有一定数量的字符,使它看起来像这样:
{
"section_id": { "$oid" : "58ef93aaa310c97c0c16bcd2" },
"name": "Name1",
"slug": "slug1"
}
你知道如何用正则表达式或其他方式改变它吗?
答案 0 :(得分:1)
我假设你在R字符串变量中有JSON。此解决方案查找section_id键并将所有内容更改为下一个逗号。
var user = db.Users.Single(x => x.Nom == formUser.Nom && x.prenom == formuser.prenom);
db.Users.Remove(user);
db.SaveChanges();