Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

Sorting JSON arrays by toString removed #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

x87-va
Copy link

@x87-va x87-va commented Oct 27, 2016

When lifting nested JSON arrays diffy looses original ordering and generates diffs.

@codecov-io
Copy link

codecov-io commented Oct 27, 2016

Current coverage is 35.02% (diff: 100%)

Merging #51 into master will decrease coverage by 0.08%

@@             master        #51   diff @@
==========================================
  Files            29         29          
  Lines           789        788     -1   
  Methods         769        753    -16   
  Messages          0          0          
  Branches         20         35    +15   
==========================================
- Hits            277        276     -1   
  Misses          512        512          
  Partials          0          0          

Powered by Codecov. Last update 2077282...8d94b76

@@ -25,7 +25,7 @@ object JsonLifter {
case JsonToken.START_ARRAY =>
node.elements.toSeq.map {
element => lift(element)
} sortBy { _.toString }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting is meant to prevent false positives caused by inconsistent orders in which the same Set can be rendered as a Json array. Since Json does not have any notion of Set we have to sort just in case the collection may have originally been a Set. The down side is that this creates a blind spot for OrderingDifferences in real lists. i.e. we have false negatives instead of false positives.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting in our case creates a lot of PrimitiveDifferences (30% - 50%) instead of OrderingDifferences.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird. Can you share a bit more about what the differences look like. By definition, if all you have are ordering differences then there should be no differences left after sorting. This might be a bug that requires a different fix.

Copy link
Author

@x87-va x87-va Nov 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a demo for this case. Try to send 10 requests https://fifth-howl-149214.appspot.com/_ah/api/diff/v1/reply through Diffy.

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Виталий Левашов seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Successfully merging this pull request may close these issues.

4 participants