I am storing jSon string as hexa-decimal or some characters string, its all working fine whan I retrieving as json string in my code, but there is one field I want to remove from the jSob object after I retrieved.
var t = StoredProcedures.SP_GlobalSearch.Execute(new SP_GlobalSearch_Params
{
Search = request.search,
SourceKey = "",
Skip = start,
Take = length,
ShowDeleted = false
}).Select(x => new SP_GlobalSearch
{
JsonObject = x.Data != null ? new JavaScriptSerializer().DeserializeObject(x.Data.Replace("", "")) : null,
Date = x.Date,
JsonObjectId = x.JsonObjectId,
SourceKey = x.SourceKey,
SourceId = x.SourceId,
TotalCount = x.TotalCount
});
var response = t?.ToList();
var jsondata = new DataTableResponse<SP_GlobalSearch>
{
totalCount = (int)response.Where(x => x.TotalCount != null).FirstOrDefault().TotalCount,
data = response.Where(x => x.TotalCount == null)
};
var jsonResult = Json(jsondata);
jsonResult.MaxJsonLength = Int32.MaxValue;
return jsonResult; I am reading the text as jSon with the below statement,
JavaScriptSerializer().DeserializeObject(x.Data.Replace("", ""))
I want to remove the violations field from it, any help please. Thanks in advance
Here is my json:
{
"InspectionResultId":846,
"InspectionResultNumber":"T00846",
"InspectionRequestId":507,
"InspectionRequestNumber":"R00507",
"CaseId":689,
"InspectionResultStatusId":605,
"EnforcementSectionId":104,
"ViolationTypeId":603,
"DateOfInspection":"\/Date(1589439600000)\/",
"InspectionComment":"send to office staff, open investigation",
"InspectedCompanyDataId":964,
"ContactTypeId":701,
"EnteredById":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"InspectionResultTimestamp":"\/Date(1588280817470)\/",
"DateCreated":"\/Date(1588280817487)\/",
"DateUpdated":"\/Date(1588281867967)\/",
"CreatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"UpdatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"Case":{
"RelatedContactId":0,
"CaseId":689,
"CaseNumber":"I00689",
"IsInvestigation":true,
"CaseStatusId":801,
"InspectionItemSourceId":211,
"EnforcementSectionId":104,
"ReminderDate":"\/Date(1590044400000)\/",
"PreCaseSummary":"send to office staff, open investigation",
"AssignedToInspectorId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"CaseTimestamp":"\/Date(1588281867403)\/",
"CaseCompanyId":964,
"DateCreated":"\/Date(1588281867437)\/",
"DateUpdated":"\/Date(1588281867840)\/",
"CreatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"UpdatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"IsDeleted":false,
"InterpreterNeeded":false,
"VoluntaryDisclosure":false,
"PenaltyAdjustment":0,
"Company":{
"ContactId":964,
"ContactTypeId":1000,
"FirstName":"04.30.2020 new co",
"Notes":"new request",
"Active":true,
"Created":"\/Date(1588279909680)\/",
"Updated":"\/Date(1588279909680)\/",
"DateCreated":"\/Date(1588279909680)\/",
"DateUpdated":"\/Date(1588279909680)\/",
"IsEJArea":false,
"CreatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"UpdatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"Classification":{
},
"Class":"Company",
"IsSpecial":false,
"Address":{
"Street1":"5678 Street",
"City":"Sacramento",
"StateCode":"CA",
"Zip":"95812",
"Country":"0"
}
}
},
"InspectionResultStatus":{
"InspectionResultStatusId":605,
"InspectionResultStatusName":"Clean",
"InspectionResultStatusSortOrder":5
},
"EnforcementSection":{
"EnforcementSectionId":104,
"EnforcementSectionName":"STBES",
"EnforcementSectionSortOrder":0,
"BranchId":2
},
"InspectedCompanyData":{
"ContactId":964,
"ContactTypeId":1000,
"FirstName":"04.30.2020 new co",
"Notes":"new request",
"Active":true,
"Created":"\/Date(1588279909680)\/",
"Updated":"\/Date(1588279909680)\/",
"DateCreated":"\/Date(1588279909680)\/",
"DateUpdated":"\/Date(1588279909680)\/",
"IsEJArea":false,
"CreatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"UpdatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"Classification":{
},
"Class":"Company",
"IsSpecial":false
},
"InspectionItems":[
{
"InspectionItemId":1054,
"InspectionItemNumber":"T00000",
"InspectionRequestId":507,
"InspectionResultId":846,
"CaseId":689,
"InspectionItemSourceId":229,
"IsCreatedInCase":false,
"ShowYearMakeModel":"",
"ShowYearMakeModelVIN":"",
"GrossWeight":0.00,
"RegHoldSet":false,
"InspectionItemTimestamp":"\/Date(1588280802553)\/",
"DateCreated":"\/Date(1588280802567)\/",
"DateUpdated":"\/Date(1588281868153)\/",
"CreatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"UpdatedByUserId":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"Violations":[
]
}
],
"CompletedBy":[
{
"IsActive":true,
"FirstName":"Daphne",
"LastName":"Greene",
"ObjectGUID":"S-1-5-21-1538631513-416410304-3002070310-33442",
"NameLoginFormat":"dgreene",
"NameFirstLast":"Daphne Greene",
"NameLastFirst":"Greene Daphne",
"Email":"daphne.greene@arb.ca.gov",
"EmailConfirmed":false,
"SecurityStamp":"e061e77e-c93e-4b9e-8497-4852b5cb4ca2",
"PhoneNumberConfirmed":false,
"TwoFactorEnabled":false,
"LockoutEnabled":false,
"AccessFailedCount":0,
"Id":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"UserName":"dgreene"
}
],
"EnteredBy":{
"IsActive":true,
"FirstName":"Daphne",
"LastName":"Greene",
"ObjectGUID":"S-1-5-21-1538631513-416410304-3002070310-33442",
"NameLoginFormat":"dgreene",
"NameFirstLast":"Daphne Greene",
"NameLastFirst":"Greene Daphne",
"Email":"daphne.greene@arb.ca.gov",
"EmailConfirmed":false,
"SecurityStamp":"e061e77e-c93e-4b9e-8497-4852b5cb4ca2",
"PhoneNumberConfirmed":false,
"TwoFactorEnabled":false,
"LockoutEnabled":false,
"AccessFailedCount":0,
"Id":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"UserName":"dgreene"
},
"MyGridContacts":[
],
"CreatedByUser":{
"IsActive":true,
"FirstName":"Daphne",
"LastName":"Greene",
"ObjectGUID":"S-1-5-21-1538631513-416410304-3002070310-33442",
"NameLoginFormat":"dgreene",
"NameFirstLast":"Daphne Greene",
"NameLastFirst":"Greene Daphne",
"Email":"daphne.greene@arb.ca.gov",
"EmailConfirmed":false,
"SecurityStamp":"e061e77e-c93e-4b9e-8497-4852b5cb4ca2",
"PhoneNumberConfirmed":false,
"TwoFactorEnabled":false,
"LockoutEnabled":false,
"AccessFailedCount":0,
"Id":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"UserName":"dgreene"
},
"UpdatedByUser":{
"IsActive":true,
"FirstName":"Daphne",
"LastName":"Greene",
"ObjectGUID":"S-1-5-21-1538631513-416410304-3002070310-33442",
"NameLoginFormat":"dgreene",
"NameFirstLast":"Daphne Greene",
"NameLastFirst":"Greene Daphne",
"Email":"daphne.greene@arb.ca.gov",
"EmailConfirmed":false,
"SecurityStamp":"e061e77e-c93e-4b9e-8497-4852b5cb4ca2",
"PhoneNumberConfirmed":false,
"TwoFactorEnabled":false,
"LockoutEnabled":false,
"AccessFailedCount":0,
"Id":"7f54fa3e-b5cd-4b2e-9490-92f64c022246",
"UserName":"dgreene"
}
}
I want to remove the Violations part from the jSon object, can you please help me in this regards thank you.
modified 11-Jun-20 18:08pm.
|