需要一些 JSON 帮助。我正在使用与此类似的 JSON:
{
GreatGrandfather: {
GrandFather: {
Father: [
{
Son: [
{
Name: "Abu Nazir",
Detail: {
Class: "3rd Grade"
}
},
{
Name: "Dexter",
Detail: {
Class: "6th Grade"
}
},
{
Name: "Rick",
Detail: {
Class: "11th Grade"
}
}
]
},
{
Son: [
{
Name: "Tom Walker",
Detail: {
Class: "3rd Grade"
}
},
{
Name: "Sgt Bastisa",
Detail: {
Class: "6th Grade"
}
},
{
Name: "The Governer",
Detail: {
Class: "11th Grade"
}
}
]
}
]
}
}
}
我的问题是如何删除 Class 值为“3rd Grade”的 Sons?所以阿布纳齐尔和汤姆沃克都将被删除,每个父亲都只有两个儿子?
另外,我如何将儿子添加到两个父亲中?
{Name: "Stewie",Detail: {Class:"Kindergarden"}}
和
{Name: "Peter",Detail: {Class:"1st Grade"}}
谢谢!