Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GroupDocsGists/7802d8091e7984403c6e98f56be0ce58 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/7802d8091e7984403c6e98f56be0ce58 to your computer and use it in GitHub Desktop.
How to accept or reject changes when comparing JSON files with C#
using (Comparer comparer = new Comparer(inFile1))
{
comparer.Add(inFile2);
comparer.Compare();
ChangeInfo[] changes = comparer.GetChanges();
foreach (var change in changes)
{
if ( change.SourceText != null
&& change.SourceText.Contains("position"))
change.ComparisonAction = ComparisonAction.Reject;
else
change.ComparisonAction = ComparisonAction.Accept;
}
comparer.ApplyChanges(outFile,
new ApplyChangeOptions { Changes = changes });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment