to_json problems with objects/hashes
-
Jonah Fox
actually that was slightly incorrect - here's an updated version
module Johnson
module SpiderMonkeyclass RubyLandProxy def to_json(arg=nil) RubyLandProxy.to_json(self) end def RubyLandProxy.to_jsonable_object proxy ret = nil if proxy.to_s == "[object Object]" ret = {} proxy.each do |k,v| ret[k] = (v.class == RubyLandProxy) ? RubyLandProxy.to_jsonable_object(v) : v end else ret = [] i = 0 proxy.each do |v| ret[i] = (v.class == RubyLandProxy) ? RubyLandProxy.to_jsonable_object(v) : v i += 1 end end ret end def RubyLandProxy.to_json proxy RubyLandProxy.to_jsonable_object(proxy).to_json end endend end
-
John Barnette
- State changed from new to resolved
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.