Posterous theme by Cory Watilo

json_pure 1.1.3 patch

Following up on a previous blog post about a JSON transformation issue, there is now a patched version of the json_pure 1.1.3 gem on GitHub. The issue had to do with transforming Hashes and Arrays to JSON when they contain objects (classes) that have their own to_json methods. A typical error message is:
lib/ruby/gems/1.8/gems/json_pure-1.1.3/lib/json/pure/generator.rb:251:in 
`to_json': wrong # of arguments(2 for 0) (ArgumentError)
See the README file and the commit history for generator.rb for more info. No warranties or guarantees that this will work for other users and uses of the json_pure gem! See the GPL license. Feedback is welcome!

by

| Viewed
times | Favorited 0 times
Filed under:            

4 Comments

Oct 21, 2008
burton miller said...
thanks, man - this saved my ass.
Nov 06, 2008
George said...
This helped me a lot. Thanks!
Jan 23, 2009
Henry said...
Thanks for this patch. I encountered the same problem with merb and jruby and the patch works well.

Another way to work-around the issue, and maybe to get better json performance is to use json-jruby gem with a patch to merb-core/bootloader.rb.

Has the patch been submitted to upstream for review? I would really love to see it fixed without a fork.

Thanks again.

May 17, 2009
Chad DePue said...
actually with json-jruby 1.1.6 this is fixed so you don't need the patch. it was broken, returning the same error, with 1.1.3.

Leave a comment...