Comments (1)
There could be some concerns with that kind of interface. Yes, internally lib compares things using interface{} representation of the JSON AST as produced by the Go encoding/json lib. But I can't say lib accepts any interface{}, because that's not true. For example code inside expects you to use UseNumber()
on go's json decoder, and never checks for float64 or int64 type in the interface{} typed values. Those types are replaced by json.Number.
Effectively we'll have to say something like: Here's the CompareValues(a, b interface{}, opts *Options)
function, but a and b values must be a result of: d := json.NewDecoder(input); d.UseNumber(); d.Decode()
. Which is a strange kind of interface to have. Not sure it's worth the effort.
Another argument against it, is that this lib is just used for testing, in tests you can encode the JSON to []byte and feed it to the lib without thinking about performance. I doubt it will make your tests drastically slower. The lib in general is not that optimized for performance anyway.
I'm not convinced about the need for such interface, but I'll leave the issue open, maybe will reconsider it one day.
And as a side note. This lib sadly is very far from the top of my maintenance effort list. I still use it in tests and it works for me, don't feel like changing anything. (This is more of a message for people who wonder why there are no commits and/or work on other issues)
from jsondiff.
Related Issues (18)
- Use UseNumber() when parsing JSON to interface{}
- option to disable printing out inse HOT 1
- Print all items in array HOT 1
- Providing nil options causes a panic HOT 1
- Wasm demo ? HOT 1
- Removing item from top of an array yields noisy output HOT 1
- The diff output should preserve the key order of the original JSON object.
- Array type attribute comparisons does not return valid results
- add optional param support array sort diff
- DefaultJSONOptions produces invalid json as diff string
- Difference is invalid/misleading when comparing a 'null' JSON value and a nested JSON value (array / object) HOT 1
- Add "ignore whitespace" option
- Clarify License
- Support displaying only areas of diff HOT 9
- Windows color support using DefaultConsoleOptions HOT 5
- Compare options are not optional HOT 2
- Allow use of an epsilon when comparing numeric values HOT 2
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 jsondiff.