Git Product home page Git Product logo

Comments (6)

ohler55 avatar ohler55 commented on August 18, 2024

It should not get triggered. Can you provide an example of how it was triggered. My tests must not be complete enough.

from oj.

magni- avatar magni- commented on August 18, 2024

Our Rails app's Gemfile includes both oj and oj_mimic_json. We also have an indirect dependency on json (the latest version, v2.6.3).

When first launching the app, the warning gets printed out. I bundle open oj'ed to add puts all over which confirmed that it's this line https://github.com/ohler55/oj/blob/v3.15.1/lib/oj/mimic.rb#L99 that causes the warning to be printed out.

I inspected JSON::PRETTY_STATE_PROTOTYPE: it's the constant defined by json rather than the one defined by oj/json (https://github.com/flori/json/blob/v2.6.3/lib/json/common.rb#L76)

I confirmed this by changing that line locally to

const_set :PRETTY_STATE_PROTOTYPE, {hello: :bug}

and then adding this to oj/json.rb:

 if defined?(JSON::PRETTY_STATE_PROTOTYPE)
+  puts JSON::PRETTY_STATE_PROTOTYPE.inspect
   warn "WARNING: oj/json is a compatability shim used by Oj. Requiring the file explicitly is no recommended."
 end
> spring stop
Spring stopped
> bundle exec spring rails r "puts :ok"
{:hello=>:bug}
WARNING: oj/json is a compatability shim used by Oj. Requiring the file explicitly is no recommended.
Running via Spring preloader in process 51676
ok

from oj.

ohler55 avatar ohler55 commented on August 18, 2024

The issue is requiring the JSON gem first. If that is done there should not be a reason to include oj/json.rb. At least that was my thinking. The issue being fixed was including the JSON gem and the oj/json caused an infinite loop. Possibly the fix is to remove or do an extra check in oj_mimic_json. Worse case I'll have the warning silenced but I'd like to explore other options first.

from oj.

ohler55 avatar ohler55 commented on August 18, 2024

Please try the latest v3.16.0.

from oj.

ohler55 avatar ohler55 commented on August 18, 2024

No response, closing.

from oj.

magni- avatar magni- commented on August 18, 2024

Sorry, I missed the notification—it is indeed fixed, thank you!

from oj.

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.