private JObject PrivacyProcessing(JObject record, IDictionary <string, string> privacyField) { var privacyRecord = new JObject(); foreach (var fieldName in privacyField.Keys) { if (privacyField[fieldName] != "Optional") { string json = record.SelectToken(fieldName).ToString(); try { var token = JToken.Parse(json); if (token is JArray) { var arr = JArray.Parse(record.SelectToken(fieldName).ToString()); privacyRecord[fieldName] = RecursivePrivacyProcess(privacyField[fieldName], arr); } else { privacyRecord.AddNewFieldFromPath(fieldName, record, privacyField[fieldName]); } } catch (Exception) { privacyRecord.AddNewFieldFromPath(fieldName, record, privacyField[fieldName]); } } } return(privacyRecord); }
public static void AddNewField(this JObject jObject, string pathField, JObject rawObject, string privacyFunction) { var nestedFields = pathField.Split(new char[] { '.' }); jObject.AddNewFieldFromPath(rawObject, nestedFields, 0, privacyFunction); }