
extlib Time.to_json in JRuby with json_pure
Reported by Idearise Admin | September 12th, 2008 @ 05:12 PM
I'm having an issue with extlib's Time.to_json method when running a Ruby script in JRuby with json_pure.
I'm seeing this problem when a Hash value is a Time instance and that Hash is being converted to_json.
It might also be occurring with an Array.to_json, but I haven't checked.
Here's a short script to run under JRuby:
require 'rubygems'
require 'extlib'
require 'json'
p [ JSON.parser, JSON.generator ]
p Time.now.to_json
h = {"created_on" => Time.now}
p h.to_json
And here's a blog post with some further details:
Comments and changes to this ticket
-
Idearise Admin September 12th, 2008 @ 05:24 PM
BTW, I'm really not sure if this is truly an extlib issue, a json_pure issue, or if it's just one of those situations where two libraries are trying to do the same thing.
-
Idearise Admin September 12th, 2008 @ 05:36 PM
I think I have JRuby-on-the-brain. It obviously will have the same error through the MRI if you require 'json/pure'. And a Time instance in an Array also throws the exception.
@@@ruby require 'rubygems' require 'extlib' require 'json/pure'
p [ JSON.parser, JSON.generator ] p Time.now.to_json
a = [Time.now] p a.to_json
h = {"created_on" => Time.now} p h.to_json
-
Idearise Admin September 12th, 2008 @ 05:38 PM
Ugh...code formatting...Sorry for the multiple comments!
require 'rubygems' require 'extlib' require 'json/pure' p [ JSON.parser, JSON.generator ] p Time.now.to_json a = [Time.now] p a.to_json h = {"created_on" => Time.now} p h.to_json
-
Idearise Admin September 17th, 2008 @ 01:55 PM
- Tag changed from extlib to extlib
If you want to close this ticket, it can be closed. I think the issue has to do more with json_pure behaving differently from the json C extension.
-
Alex Coles November 29th, 2008 @ 08:53 AM
- Tag changed from extlib to extlib, jruby, json
- Assigned user cleared.
-
Dan Kubb (dkubb) November 30th, 2008 @ 02:51 PM
- State changed from new to invalid
- Assigned user set to Dan Kubb (dkubb)
Marking this invalid as per reporter's comment.
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 »