jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-1767

JRuby needs a fast JSON library

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Wish Wish
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: JRuby 1.1.2
  • Component/s: Extensions
  • Labels:
    None

Description

This is a request for someone in the community to implement Florian Frank's fast JSON library (http://rubyforge.org/projects/json/) using an equivalent Java library to produce a JRuby-compatible gem. I expect more and more folks are going to be using JSON as a wire format for remote APIs, and JRuby would suffer if we don't have an equivalent to Florian's json gem.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. File
    parser_java.rl
    28/Jan/08 10:21 AM
    18 kB
    Marco Walther
  2. Java Source File
    ParserService.java
    28/Jan/08 10:21 AM
    52 kB
    Marco Walther

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Salil Joshi added a comment - 27/Jan/08 11:39 AM

I'd like to work on this one. But are you saying you want an interface identical to Frank's lib, or are you just looking for "a" JSON lib?

Show
Salil Joshi added a comment - 27/Jan/08 11:39 AM I'd like to work on this one. But are you saying you want an interface identical to Frank's lib, or are you just looking for "a" JSON lib?
Hide
Permalink
Mazdak Rezvani added a comment - 27/Jan/08 11:48 AM

I have been looking at the possibility of doing this too. Essentially we want to swap out the C parts of the Ragel code and replace it with Java. This seems like the best and most compatible approach.

Mongrel and Hpricot are good examples of this approach.

Show
Mazdak Rezvani added a comment - 27/Jan/08 11:48 AM I have been looking at the possibility of doing this too. Essentially we want to swap out the C parts of the Ragel code and replace it with Java. This seems like the best and most compatible approach. Mongrel and Hpricot are good examples of this approach.
Hide
Permalink
Nick Sieger added a comment - 27/Jan/08 12:08 PM

Just in case someone else has already started on this, I thought I'd mention that a coworker of mine is almost done with a port of Florian's library. I'll try to get him to put the patch here and see if we can get it pushed upstream.

Show
Nick Sieger added a comment - 27/Jan/08 12:08 PM Just in case someone else has already started on this, I thought I'd mention that a coworker of mine is almost done with a port of Florian's library. I'll try to get him to put the patch here and see if we can get it pushed upstream.
Hide
Permalink
Marco Walther added a comment - 28/Jan/08 10:17 AM

OK, I'm that coworker of Nick I've a ragel file (and the generated Java source) for the parser. I've still at least two problems (aside from a very hacked environment.

  • UTF-16 - UTF-8 conversions are not done. ('\uDDDD' in the source -> Java -> JRuby -> ...)
  • I still have many failures in the tests. But that could be related to my setup.

I was not planing on releasing the code quite yet, but Nick sent me an email yesterday evening about the movement here. So I'll attach my two files for others to look/play.

Show
Marco Walther added a comment - 28/Jan/08 10:17 AM OK, I'm that coworker of Nick I've a ragel file (and the generated Java source) for the parser. I've still at least two problems (aside from a very hacked environment.
  • UTF-16 - UTF-8 conversions are not done. ('\uDDDD' in the source -> Java -> JRuby -> ...)
  • I still have many failures in the tests. But that could be related to my setup.
I was not planing on releasing the code quite yet, but Nick sent me an email yesterday evening about the movement here. So I'll attach my two files for others to look/play.
Hide
Permalink
Marco Walther added a comment - 28/Jan/08 10:21 AM

The first version of the Ragel file. (I used Ragel 6.0 if that makes a difference.)

Show
Marco Walther added a comment - 28/Jan/08 10:21 AM The first version of the Ragel file. (I used Ragel 6.0 if that makes a difference.)
Hide
Permalink
Marco Walther added a comment - 28/Jan/08 10:21 AM

The generated Java Source.

Show
Marco Walther added a comment - 28/Jan/08 10:21 AM The generated Java Source.
Hide
Permalink
Daniel Luz added a comment - 28/Jan/08 9:29 PM

Whoa, where did you all suddenly come from? One week ago there were no comments at all here or on Charles' blog, other than mine!

This weekend I finally took the time to work on this project, and I already have a fully working port of the json library. Includes both the Generator and the Parser, and passes all the tests that come bundled with the original library with no changes at all to the ruby part of the library (i.e., a drop-in replacement to json/ext).

It is hosted on: http://rubyforge.org/projects/json-jruby/
No releases yet (I still need to check what would be the best way to package it), but you may want to check the subversion repository.

Show
Daniel Luz added a comment - 28/Jan/08 9:29 PM Whoa, where did you all suddenly come from? One week ago there were no comments at all here or on Charles' blog, other than mine! This weekend I finally took the time to work on this project, and I already have a fully working port of the json library. Includes both the Generator and the Parser, and passes all the tests that come bundled with the original library with no changes at all to the ruby part of the library (i.e., a drop-in replacement to json/ext). It is hosted on: http://rubyforge.org/projects/json-jruby/ No releases yet (I still need to check what would be the best way to package it), but you may want to check the subversion repository.
Hide
Permalink
Charles Oliver Nutter added a comment - 28/Jan/08 9:45 PM

I love open source.

It sounds as though Daniel and Marco should collaborate on what has been done. Daniel's implementation might need some smithing that Marco could provide, and at the very least it's always nice to have two experts on a given library (in preference to two libraries). And I imagine Marco has learned a valuable lesson about keeping projects secret for too long

Seriously though, we really appreciate all efforts to help fill this gap, especially given the number of REST-based sites and services that will probably use JSON in the future. I'll be watching this bug for updates until we all decide together the problem is completely solved.

Show
Charles Oliver Nutter added a comment - 28/Jan/08 9:45 PM I love open source. It sounds as though Daniel and Marco should collaborate on what has been done. Daniel's implementation might need some smithing that Marco could provide, and at the very least it's always nice to have two experts on a given library (in preference to two libraries). And I imagine Marco has learned a valuable lesson about keeping projects secret for too long Seriously though, we really appreciate all efforts to help fill this gap, especially given the number of REST-based sites and services that will probably use JSON in the future. I'll be watching this bug for updates until we all decide together the problem is completely solved.
Hide
Permalink
Charles Oliver Nutter added a comment - 28/Jan/08 9:46 PM

Oh, and I should mention one recommendation regarding packaging: please try to work with Florian to get this released as a platform-specific version of the same gem. Differently-named gems quickly fail to scale because so many other libraries depend on specific names.

Show
Charles Oliver Nutter added a comment - 28/Jan/08 9:46 PM Oh, and I should mention one recommendation regarding packaging: please try to work with Florian to get this released as a platform-specific version of the same gem. Differently-named gems quickly fail to scale because so many other libraries depend on specific names.
Hide
Permalink
Marco Walther added a comment - 29/Jan/08 11:39 AM

I'm around for a long time (But not so long @JRuby

I'll look at your code. If it works, I'll have no problem using it. I simply started on Friday to look into the json parser because we need a fast one. But I have enough other stuff to do as well

Thanks.

Show
Marco Walther added a comment - 29/Jan/08 11:39 AM I'm around for a long time (But not so long @JRuby I'll look at your code. If it works, I'll have no problem using it. I simply started on Friday to look into the json parser because we need a fast one. But I have enough other stuff to do as well Thanks.
Hide
Permalink
Daniel Luz added a comment - 29/Jan/08 12:01 PM

I used this project to learn about JRuby's internals, so on the beginning I was a bit lost (that's also why I didn't announce it before; I first wanted to make sure I was able to work properly with JRuby). I believe I have already ironed out most early mistakes I made, but there sure is still something to learn.

I still plan to document and explain the most important design differences from the C version and refactor some areas (the GeneratorMethodsLoader feels quite messy), but it should be quite workable right now.

Show
Daniel Luz added a comment - 29/Jan/08 12:01 PM I used this project to learn about JRuby's internals, so on the beginning I was a bit lost (that's also why I didn't announce it before; I first wanted to make sure I was able to work properly with JRuby). I believe I have already ironed out most early mistakes I made, but there sure is still something to learn. I still plan to document and explain the most important design differences from the C version and refactor some areas (the GeneratorMethodsLoader feels quite messy), but it should be quite workable right now.
Hide
Permalink
Charles Oliver Nutter added a comment - 29/Jan/08 12:07 PM

Daniel: that's excellent. I'll defer to you to decide when this bug is resolved (perhaps after there's an installable gem available, ideally as simply a separate platform for Florian's library).

Nick, Marco: it would be great if you guys could have a look and see if the existing code works the way you'd hope for project K.

Show
Charles Oliver Nutter added a comment - 29/Jan/08 12:07 PM Daniel: that's excellent. I'll defer to you to decide when this bug is resolved (perhaps after there's an installable gem available, ideally as simply a separate platform for Florian's library). Nick, Marco: it would be great if you guys could have a look and see if the existing code works the way you'd hope for project K.
Hide
Permalink
Daniel Luz added a comment - 02/Feb/08 1:53 PM

An update on the project status:

I've released a gem on the project page. It's named json_jruby for now (I've sent an email to Florian; let's see what he says), but once installed it goes just like the original libraries (i.e. require "json", not "json_jruby").

From my tests, after the usual warm-up, the parser's performance is amazingly similar to json-C. The generator is a bit slower, but I plan to investigate that.

By the way, I only targeted JRuby trunk. It works with 1.1rc1, but breaks on 1.1b1 (due to RubyHash#visitAll, it seems). If you think some particular version is worth targeting for, please mention it, I can take a look at that.

Nick and Marco, this version should be good enough for testing. Please report anything wrong, or if you need support for a specific JRuby release.

Show
Daniel Luz added a comment - 02/Feb/08 1:53 PM An update on the project status: I've released a gem on the project page. It's named json_jruby for now (I've sent an email to Florian; let's see what he says), but once installed it goes just like the original libraries (i.e. require "json", not "json_jruby"). From my tests, after the usual warm-up, the parser's performance is amazingly similar to json-C. The generator is a bit slower, but I plan to investigate that. By the way, I only targeted JRuby trunk. It works with 1.1rc1, but breaks on 1.1b1 (due to RubyHash#visitAll, it seems). If you think some particular version is worth targeting for, please mention it, I can take a look at that. Nick and Marco, this version should be good enough for testing. Please report anything wrong, or if you need support for a specific JRuby release.
Hide
Permalink
Charles Oliver Nutter added a comment - 02/Feb/08 2:02 PM

I wouldn't sweat targeting it for anything other than trunk at the moment. We'll get another 1.1 RC out soon, so it's a good way to go.

I'm definitely looking forward to hearing from Nick and Marco.

Show
Charles Oliver Nutter added a comment - 02/Feb/08 2:02 PM I wouldn't sweat targeting it for anything other than trunk at the moment. We'll get another 1.1 RC out soon, so it's a good way to go. I'm definitely looking forward to hearing from Nick and Marco.
Hide
Permalink
Thomas E Enebo added a comment - 02/Feb/08 2:03 PM

RC1 and trunk should be fine to target. Ultimately only 1.1 final people will be using this soon.

Show
Thomas E Enebo added a comment - 02/Feb/08 2:03 PM RC1 and trunk should be fine to target. Ultimately only 1.1 final people will be using this soon.
Hide
Permalink
Gregory Murphy added a comment - 03/Feb/08 10:33 PM

I was the one who first asked about a JRuby port, I'll be happy to do some testing. I already have a few test suites for two different projects that I was using to test performance of the ActiveResource JSON implementation in Rails 2, and Florian's JSON gem. The tests involve serializing and de-serializing basic ActiveRecord models, so the JSON isn't that complicated.

I'll add comments to this issue if I find any problems.

Show
Gregory Murphy added a comment - 03/Feb/08 10:33 PM I was the one who first asked about a JRuby port, I'll be happy to do some testing. I already have a few test suites for two different projects that I was using to test performance of the ActiveResource JSON implementation in Rails 2, and Florian's JSON gem. The tests involve serializing and de-serializing basic ActiveRecord models, so the JSON isn't that complicated. I'll add comments to this issue if I find any problems.
Hide
Permalink
Gregory Murphy added a comment - 04/Feb/08 11:24 AM

Where is the gem? I scoured the JRuby project page and wiki, and the jruby-extras and json projects at RubyForge, couldn't find it.

Show
Gregory Murphy added a comment - 04/Feb/08 11:24 AM Where is the gem? I scoured the JRuby project page and wiki, and the jruby-extras and json projects at RubyForge, couldn't find it.
Hide
Permalink
Daniel Luz added a comment - 04/Feb/08 12:00 PM

It's on the "JSON-JRuby" (not a very creative name) project:
http://rubyforge.org/projects/json-jruby/

Show
Daniel Luz added a comment - 04/Feb/08 12:00 PM It's on the "JSON-JRuby" (not a very creative name) project: http://rubyforge.org/projects/json-jruby/
Hide
Permalink
Charles Oliver Nutter added a comment - 12/May/08 2:06 PM

I'm going to mark this fixed, since the json-jruby gem has been out for a while. Hopefully it will get integrated into the native gem, so there's a single place to install from, but this is a solved problem now.

Show
Charles Oliver Nutter added a comment - 12/May/08 2:06 PM I'm going to mark this fixed, since the json-jruby gem has been out for a while. Hopefully it will get integrated into the native gem, so there's a single place to install from, but this is a solved problem now.
Hide
Permalink
wenshao added a comment - 07/Aug/11 7:40 PM

fastjson 1.1.2 is fast!

the benchmark test results:
------------------------
serialize deserialize size compressed size
java serialize 8654 43787 889 541
hessian 6725 10460 501 313
protobuf 2964 1745 239 149
thrift 3177 1949 349 197
avro 3520 1948 221 133
json-lib 45788 149741 485 263
jackson 3052 4161 503 271
fastjson 2595 1472 468 251

----------------------

How to get it?

If you're Maven user, just use our maven repository(http://code.alibabatech.com/mvn/releases/) with folloging dependency

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.1.2</version>
</dependency>
Downlaods

Binary : http://code.alibabatech.com/mvn/releases/com/alibaba/fastjson/1.1.2/fastjson-1.1.2.jar
Source :http://code.alibabatech.com/mvn/releases/com/alibaba/fastjson/1.1.2/fastjson-1.1.2-sources.jar
Subversion : http://code.alibabatech.com/svn/fastjson/trunk/fastjson/

Show
wenshao added a comment - 07/Aug/11 7:40 PM fastjson 1.1.2 is fast! the benchmark test results: ------------------------ serialize deserialize size compressed size java serialize 8654 43787 889 541 hessian 6725 10460 501 313 protobuf 2964 1745 239 149 thrift 3177 1949 349 197 avro 3520 1948 221 133 json-lib 45788 149741 485 263 jackson 3052 4161 503 271 fastjson 2595 1472 468 251 ---------------------- How to get it? If you're Maven user, just use our maven repository(http://code.alibabatech.com/mvn/releases/) with folloging dependency <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.1.2</version> </dependency> Downlaods Binary : http://code.alibabatech.com/mvn/releases/com/alibaba/fastjson/1.1.2/fastjson-1.1.2.jar Source :http://code.alibabatech.com/mvn/releases/com/alibaba/fastjson/1.1.2/fastjson-1.1.2-sources.jar Subversion : http://code.alibabatech.com/svn/fastjson/trunk/fastjson/

People

  • Assignee:
    Charles Oliver Nutter
    Reporter:
    Charles Oliver Nutter
Vote (1)
Watch (7)

Dates

  • Created:
    22/Dec/07 6:52 AM
    Updated:
    07/Aug/11 7:40 PM
    Resolved:
    12/May/08 2:06 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.