Related Article(s):
Created
May 17, 2024 21:02
-
-
Save GroupDocsGists/7802d8091e7984403c6e98f56be0ce58 to your computer and use it in GitHub Desktop.
How to accept or reject changes when comparing JSON files with C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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