Giter Club home page Giter Club logo

Comments (4)

luckygerbils avatar luckygerbils commented on August 16, 2024 2

I sent a pull request here that I think is a better solution to this than what I originally posted here. Let me know what you think.

from json-diff.

luckygerbils avatar luckygerbils commented on August 16, 2024

I think I've identified what the problem is. This is a hacky fix/workaround, but probably not the right solution.

The issue is that, when scalarizing the first array, the original index of each object in the array is tracked only incidentally via the object entry position in fuzzyOriginals. But since the initial "a" element is a scalar already, it isn't put into fuzzyOriginals and therefore the entry position of every subsequent object vs it's actual original index is off by one.

My hacky fix just adds a placeholder for any actual scalar values to fuzzyOriginals so that the indexes match up. This appears to fix the issue, at least in the test case I added.

This doesn't feel like the best solution though. It seems like it would be better to explicitly remember the original index of each scalarized value by storing something like originals[key] = { item, index } instead of originals[key] = item. This requires changes to the descalarizing code though, which I haven't looked at yet. I can do that and send a pull request if my interpretation of this issue sounds correct to you.

from json-diff.

ewoudenberg avatar ewoudenberg commented on August 16, 2024

from json-diff.

tuct avatar tuct commented on August 16, 2024

We have the exact same issue,
+1 for merging the PR soon and thanks a lot to everyone involved!

from json-diff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.