This help site has been deprecated. Please send your requests to

Java support for the "json" gem

bascule's Avatar


17 Jun, 2010 06:15 PM

The "json" gem presently only functions under MRI or other Ruby implementations that support the traditional C extension API, mkmf.rb, etc.

I'd like to push a Java version (specifically the json-jruby gem modified to be named simply "json") as there are gems (e.g. Resque) which explicitly depend on "json" and are therefore uninstallable on JRuby unless I push my custom "json" gem to an internal gem server, or hand modify the gems that depend on "json" and remove this dependency. However, it seems to me that the best solution to this problem is to release a Java-platform "json" gem on itself.

I've contacted Frank Florian, the maintainer of the "json" gem about this. I'm wondering what to do if I don't receive a response.

  1. Support Staff 1 Posted by Nick Quaranto on 17 Jun, 2010 06:29 PM

    Nick Quaranto's Avatar

    Roping in the email we have for the owner of the json gem. Yeah, it seems like having a separate gem would not be ideal (like json_java a la json_pure). I'm definitely not going to preempt ownership on a gem that has 200k+ downloads and it should definitely be up to the author here.

    (I'm also surprised there isn't a mailing list or something at this point, especially since the gem has been used in nearly every app I've worked on!)

    If there's anything I can do here to help let me know.

  2. 2 Posted by bascule on 17 Jun, 2010 06:34 PM

    bascule's Avatar

    I'll wait for the author's reply and hopefully I can get him to push the Java version for me.

  3. 3 Posted by bascule on 18 Jun, 2010 03:01 AM

    bascule's Avatar

    I received this reply from the author of the json-jruby gem:

    "I must say I've tried to contact Flori several times since the first releases of json-jruby back in 2008, but never got a reply."

    As it exists presently, installing "json" on JRuby is completely broken, since it tries to build a native extension. That said, I don't see what harm releasing a -java platform "json" gem could do, unless someone were to mistakenly overwrite the standard gem.

    This is particularly troublesome when dealing with gems that explicitly require "json", because even if I include json-jruby in my bundler configuration (which works as a drop-in replacement) it still tries to pull in "json" and completely breaks.

    I've linked the author of the json-jruby gem to this thread. Perhaps he can opine directly. My opinion is these are two projects which implement the same functionality for different platforms. It would be nice if both were allowed to commit under the name "json".

  4. 4 Posted by mernen on 19 Jun, 2010 12:21 AM

    mernen's Avatar

    I'm the author of json-jruby.

    Since its inception, on JRUBY-1767, json-jruby had the intent of being the java release of json, but as Tony quoted, I never got a reply from Florian.

    The only issues I see with the merging are that my release process needs some improvement (though I do have some plans to make use of Ant/Rake integration on JRuby 1.5) and keeping the two on track (i.e. should flori wait until I port any changes before releasing a new C version, or can we keep the Java version a few hours/days late?).

    As for the course of action, I'm not sure. I don't think taking ownership of the json gem would be a good idea.

  5. 5 Posted by bascule on 19 Jun, 2010 04:12 PM

    bascule's Avatar

    I don't think you need to "take ownership" per se... can't multiple people push to the same gem?

  6. 6 Posted by James A. Rosen on 25 Jun, 2010 12:15 AM

    James A. Rosen's Avatar

    I know this isn't exactly a solution to the problem at hand, since you would have to go in and much with all your dependencies' dependencies on JSON, but using things like multi_json do help with this problem.

    One idea would be to change multi_json so it "swallows" calls to require 'json' if it has already loaded an engine. That would let you do the following:

    # very early in your application load:
    require 'multi_json'
    MultiJson.engine = :json_pure # or a custom Java engine
    # ...
    # later:
    require 'something_that_requires_json' # but MultiJson eats the require!
  7. 7 Posted by bascule on 25 Jun, 2010 12:41 AM

    bascule's Avatar

    The problem isn't with the gem loading, but the gem dependencies themselves. Bundler pulls in the "json" gem because it's required by "resque".

    One suggestion I heard was if json-jruby can't be published under "json", perhaps we could talk to the yajl folks and ask about publishing it under that name. (ed: scratch that, it won't work)

  8. 8 Posted by James A. Rosen on 25 Jun, 2010 12:46 AM

    James A. Rosen's Avatar

    I'm sorry - I didn't get that it was a dependency-resolution-time (Rubygems) rather than a runtime require issue. Perhaps you could install a dummy 'json' gem? That way, so long can get something load load that calls itself 'JSON' before you load 'resque', everything should resolve.

    It's a hack, to be sure. All I'm saying is that it's a temporary fix that should work.

  9. 9 Posted by bascule on 14 Jul, 2010 09:00 PM

    bascule's Avatar

    For what it's worth this is now the highest voted issue on the json gem issue tracker on github:

    Still no response from Florian. Several people have emailed him over the course of the past two years. I've emailed him on github and created that issue on the tracker. Headius asked ruby-talk if anyone knew how to get ahold of him with no answer.

    I think we've done our due diligence at this point trying to get ahold of him. He just isn't responsive.

  10. Support Staff 10 Posted by Nick Quaranto on 16 Jul, 2010 10:11 PM

    Nick Quaranto's Avatar

    We've given Charlie (headius) ownership to push java specific versions. Florian, if you ever read this, please let someone else maintain the project if you're not up for it anymore...the community needs it! Thanks, folks.

  11. Nick Quaranto closed this discussion on 16 Jul, 2010 10:11 PM.

  12. 11 Posted by John Barnette on 16 Jul, 2010 10:17 PM

    John Barnette's Avatar

    Small additional blame note for the future: Nick Quaranto, John Barnette, and Eric Hodel made the decision to open the JSON gem to Charlie, after consulting with other members of the RubyGems and RubyForge teams.

    Before making this decision, we spent several months trying to get ahold of the current maintainer. This ticket only captures the final month of the process.

  13. bascule re-opened this discussion on 16 Jul, 2010 10:20 PM

  14. 12 Posted by bascule on 16 Jul, 2010 10:20 PM

    bascule's Avatar

    Thank you very much! As I'm sure you can tell from the github thread, this was a major sticking point for a lot of people and I'm very glad to see you could come to a solution on it.

  15. Nick Quaranto closed this discussion on 16 Jul, 2010 10:22 PM.

Discussions are closed to public comments.
If you need help with please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac