
dm-types interacts badly with JSON gem
Reported by David R. MacIver | September 28th, 2010 @ 07:02 AM | in 1.1
In that it basically prevents anything from working correctly. The attached file when run will blow up with:
/opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/common.rb:65: warning: already initialized constant State
/opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/common.rb:66: warning: already initialized constant SAFE_STATE_PROTOTYPE
/opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/common.rb:67: warning: already initialized constant FAST_STATE_PROTOTYPE
/opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/common.rb:74: warning: already initialized constant PRETTY_STATE_PROTOTYPE
/opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/pure.rb:76: warning: already initialized constant JSON_LOADED
/opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/pure/generator.rb:318:in `to_json': wrong argument type JSON::Pure::Generator::State (expected Data) (TypeError)
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/pure/generator.rb:318:in `json_transform'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/pure/generator.rb:315:in `each'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/pure/generator.rb:315:in `json_transform'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/json-1.4.6/lib/json/pure/generator.rb:302:in `to_json'
from dm_types_and_json.rb:16
Comments and changes to this ticket
-
Martin Gamsjaeger (snusnu) October 29th, 2010 @ 02:38 PM
- State changed from new to confirmed
David,
dm-types
already doesrequire 'json/pure'
since this commit. I can confirm however, thatrequire 'json'
in your attached script raises the error you see. I'm not sure what needs to be done here.Any ideas?
-
Piotr Solnica (solnic) November 1st, 2010 @ 12:57 PM
Jon suggested we should try out this one: https://rubygems.org/gems/multi_json
-
Piotr Solnica (solnic) November 1st, 2010 @ 12:57 PM
- Milestone set to 1.1
- Assigned user set to Piotr Solnica (solnic)
- Milestone order changed from 196286 to 0
-
Alexander Sorokin November 3rd, 2010 @ 10:34 AM
It would be great if Datamapper never used global json gem. In a large app there are too many things that use it to easily swap it around.
It'd be great to have DM-scoped alias for json and let the user assign a different implementation of json gem. E.g.
DM::Json = JSON
or
DM::Json = Yajl -
Piotr Solnica (solnic) February 9th, 2011 @ 06:39 AM
- State changed from confirmed to resolved
we no longer require json/pure also we don't require json if JSON is already defined. I think the problem should be gone, please reopen if I'm wrong. Closing for now.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »