0
Im新的Json和我我想從我的JObject過濾不需要的信息。 我有一個JObject如下:從Jobject刪除屬性c#
{
"A": "sr",
"B": {
"B1": "some data",
"B2": "some data,
"Values": [
{
"C1": "some info",
"C2": someinfo",
"C3": {
"D1": "some info",
"D2": [
"cat",
"dog",
"fish"
],
"D3": "some info"
},
"C4": "some info",
"C5": "some info"
},
{
"C1": "some info",
"C2": someinfo",
"C3": {
"D1": "some info",
"D2": [
"cat",
"dog"
],
"D3": "some info"
},
"C4": "some info",
"C5": "some info"
},
{
"C1": "some info",
"C2": someinfo",
"C3": {
"D1": "some info",
"D2": [
"cat",
"dog"
],
"D3": "some info"
},
"C4": "some info",
"C5": "some info"
}
]
}
}
,我想進行掃描,如果值[I] .C3.D2不包括 「魚」,我想刪除值[I],所以我想我的新(編輯後)JObject看起來像這樣:
{
"A": "sr",
"B": {
"B1": "some data",
"B2": "some data,
"Values": [
{
"C1": "some info",
"C2": someinfo",
"C3": {
"D1": "some info",
"D2": [
"cat",
"dog",
"fish"
],
"D3": "some info"
},
"C4": "some info",
"C5": "some info"
},
{
"C1": "some info",
"C2": someinfo",
"C3": {
"D1": "some info",
"D2": [
"cat",
"fish"
],
"D3": "some info"
},
"C4": "some info",
"C5": "some info"
}
]
}
}
什麼是最好的和最乾淨的方式呢?
將您的jsons轉換爲對象列表,使用linq過濾並從對象再生成jsons。 –
怎麼樣?它已經是一個對象(JObject)。 – voldemort