Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples/docs #1

Open
mcintyre321 opened this issue Jun 27, 2017 · 4 comments
Open

Examples/docs #1

mcintyre321 opened this issue Jun 27, 2017 · 4 comments

Comments

@mcintyre321
Copy link

mcintyre321 commented Jun 27, 2017

Hi, I was wondering if you have any examples/docs on how to do a compare with and object-key-order-insensitive comparer?

thanks
Harry

@Patrickkk
Copy link
Owner

Patrickkk commented Jun 28, 2017

We can say documentation is lacking indeed ;) can you provide an example of what want to compare?
if you want to compare array items based on keys different than the index you can implement IArrayKeySelector and pass it in the contructor of JTokenComparer(IArrayKeySelector)

It gets called for every array so you need to check if you are comparing the correct type.

example implementation:

public object SelectArrayKey(JToken token, int index)
{
	if (IsSpecificArrayIWantToCompare(token))
	{
		return token.Value<string>("KeyValueOnObject");
	}
	
	return index; //default
}

@darsh142012
Copy link

how to filter all the differences and get new and old values

@darsh142012
Copy link

i mean i need object with only diffrences with old and new values and few more properties only.

@Patrickkk
Copy link
Owner

Patrickkk commented Jun 29, 2019

It is possible to do this, have a look at the "ComparrisonResultTextExporter.cs" it recursively loops through all the comparison results to print a report. However there is no functionality build in that returns only the difference. It contains additional information about the comparison performed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants