Code Monkey home page Code Monkey logo

Comments (1)

nsf avatar nsf commented on September 28, 2024

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)

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.