-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MultiJSON assumes that the JSON ext is loaded if defined?(::JSON::JSON_LOADED) #196
Comments
I'll try to make a PR for this. |
An additional confusing thing is that
|
So I guess we should check for |
* JSON::JSON_LOADED is also set by json/pure and so it is not enough to detect if the JSON native extension is loaded. * JSON::Ext is not enough either, because json_pure includes json/ext.rb. * JSON::Ext::Parser is only defined if the native extension is loaded so that is reliable. * Fixes intridea#196 * See that issue for details.
* JSON::JSON_LOADED is also set by json/pure and so it is not enough to detect if the JSON native extension is loaded. * JSON::Ext is not enough either, because json_pure includes json/ext.rb. * JSON::Ext::Parser is only defined if the native extension is loaded so that is reliable. * Fixes intridea#196 * See that issue for details.
PR to fix this: #197 |
See
multi_json/lib/multi_json.rb
Line 50 in 6686481
But that is unfortunately incorrect, because JSON pure also defines that constant:
https://github.com/flori/json/blob/b20cdca8eb03297132bcf3b786eba602fa04ca37/lib/json/pure.rb#L14
I think using
defined?(::JSON::Ext)
would work better instead.This causes an issue on TruffleRuby where JSON pure is used by default (and
require 'json/ext'
raises unless thejson
gem is installed additionally).If
json
is required beforemulti_json
, then multi_json raises an error: oracle/truffleruby#2032 (comment)On MRI it's quite confusing as it will detect JSON pure as
:json_gem
(same issue), but still work because it will thenrequire 'json/ext'
which will work (but have 2 versions of JSON loaded, so it seems suboptimal).The text was updated successfully, but these errors were encountered: