Comments (4)
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.
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.
from json-diff.
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)
- BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default HOT 4
- The -x option doesn't seem to be working? HOT 3
- The returned result is not as expected HOT 2
- Need lib/colorize method to convert diffData to diffString HOT 1
- How to use the exclude option in ES5 or ES6 HOT 2
- Elisions: Add for objects and custom localization
- outputNewOnly = true loose colours and previous value
- Can't resolve 'os' in '/node_modules/colors/lib/system' HOT 4
- Add typescript types
- Floats with zeros after decimal point and integers are treated as identical HOT 2
- The --output-keys option not working? HOT 2
- 1.0.4 version makes the terminal so messy HOT 1
- Propose new features: combine diffs and restore them HOT 2
- disable console logging HOT 3
- Browser exception when deployed under Nuxt 3 HOT 7
- Browser issue when using vite HOT 3
- Long arrays that do not change are showing as changed
- Suggestion: outputKeys & full should output the property value even if it is in excludeKeys
- Storing objects in the result array in spite of pushing array into another array
- 1.0.3 breaks webpack build
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-diff.