I am receiving JSON where I need to delete one property "original_0" form all the responses. I am working on c#. I am not sure how I can delete the property.
Below is JSON
{
"entity": [{
"JobId": 725454,
"Operation Type": "Backup",
"Client": "sgkcovldidbdev01",
"Agent": "Oracle Database",
"Instance": "INFSGDEV",
"BackupSet": "default",
"Subclient": "ArchiveLog",
" Backup Type": "Full",
"Start Time": "2020-08-21T18:30:19.000",
"End Time": "2020-08-21T18:32:14.000",
"Duration in Mins": 2,
"Size of Application": 56623104,
"Job Status": "Completed",
"dt": "2020-08-21T00:00:00.000",
"age": 0,
"original_0": {
"numberOfDays": "2",
"serverName": "sgkcovldidbdev01"
}
},
{
"JobId": 724699,
"Operation Type": "Backup",
"Client": "sgkcovldidbdev01",
"Agent": "Oracle Database",
"Instance": "INFSGDEV",
"BackupSet": "default",
"Subclient": "ArchiveLog",
" Backup Type": "Full",
"Start Time": "2020-08-21T12:30:09.000",
"End Time": "2020-08-21T12:31:09.000",
"Duration in Mins": 1,
"Size of Application": 95420416,
"Job Status": "Completed",
"dt": "2020-08-21T00:00:00.000",
"age": 0,
"original_0": {
"numberOfDays": "2",
"serverName": "sgkcovldidbdev01"
}
},
{
"JobId": 724056,
"Operation Type": "Backup",
"Client": "sgkcovldidbdev01",
"Agent": "Oracle Database",
"Instance": "INFSGDEV",
"BackupSet": "default",
"Subclient": "ArchiveLog",
" Backup Type": "Full",
"Start Time": "2020-08-21T06:30:11.000",
"End Time": "2020-08-21T06:31:10.000",
"Duration in Mins": 1,
"Size of Application": 333447168,
"Job Status": "Completed",
"dt": "2020-08-21T00:00:00.000",
"age": 0,
"original_0": {
"numberOfDays": "2",
"serverName": "sgkcovldidbdev01"
}
},
{
"JobId": 723035,
"Operation Type": "Backup",
"Client": "sgkcovldidbdev01",
"Agent": "Oracle Database",
"Instance": "INFSGDEV",
"BackupSet": "default",
"Subclient": "ArchiveLog",
" Backup Type": "Full",
"Start Time": "2020-08-21T00:30:10.000",
"End Time": "2020-08-21T00:31:11.000",
"Duration in Mins": 1,
"Size of Application": 115343360,
"Job Status": "Completed",
"dt": "2020-08-21T00:00:00.000",
"age": 0,
"original_0": {
"numberOfDays": "2",
"serverName": "sgkcovldidbdev01"
}
}
]}
After deleting "original_0" JSON should be like below.
{
"entity": [{
"JobId": 725454,
"Operation Type": "Backup",
"Client": "sgkcovldidbdev01",
"Agent": "Oracle Database",
"Instance": "INFSGDEV",
"BackupSet": "default",
"Subclient": "ArchiveLog",
" Backup Type": "Full",
"Start Time": "2020-08-21T18:30:19.000",
"End Time": "2020-08-21T18:32:14.000",
"Duration in Mins": 2,
"Size of Application": 56623104,
"Job Status": "Completed",
"dt": "2020-08-21T00:00:00.000",
"age": 0
},
{
"JobId": 724699,
"Operation Type": "Backup",
"Client": "sgkcovldidbdev01",
"Agent": "Oracle Database",
"Instance": "INFSGDEV",
"BackupSet": "default",
"Subclient": "ArchiveLog",
" Backup Type": "Full",
"Start Time": "2020-08-21T12:30:09.000",
"End Time": "2020-08-21T12:31:09.000",
"Duration in Mins": 1,
"Size of Application": 95420416,
"Job Status": "Completed",
"dt": "2020-08-21T00:00:00.000",
"age": 0
},
{
"JobId": 724056,
"Operation Type": "Backup",
"Client": "sgkcovldidbdev01",
"Agent": "Oracle Database",
"Instance": "INFSGDEV",
"BackupSet": "default",
"Subclient": "ArchiveLog",
" Backup Type": "Full",
"Start Time": "2020-08-21T06:30:11.000",
"End Time": "2020-08-21T06:31:10.000",
"Duration in Mins": 1,
"Size of Application": 333447168,
"Job Status": "Completed",
"dt": "2020-08-21T00:00:00.000",
"age": 0
},
{
"JobId": 723035,
"Operation Type": "Backup",
"Client": "sgkcovldidbdev01",
"Agent": "Oracle Database",
"Instance": "INFSGDEV",
"BackupSet": "default",
"Subclient": "ArchiveLog",
" Backup Type": "Full",
"Start Time": "2020-08-21T00:30:10.000",
"End Time": "2020-08-21T00:31:11.000",
"Duration in Mins": 1,
"Size of Application": 115343360,
"Job Status": "Completed",
"dt": "2020-08-21T00:00:00.000",
"age": 0
}
]}
I am using the below code to delete the property but it is not working.
var jsonRes = JsonConvert.DeserializeObject<dynamic>(json);
foreach (var item in jsonRes)
{
item.Property("original_0").Remove();
// Console.WriteLine(item.ToString());
}
Thanks