Skip to content

Instantly share code, notes, and snippets.

@msavy
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msavy/884642ff7a8b835a4d9e to your computer and use it in GitHub Desktop.
Save msavy/884642ff7a8b835a4d9e to your computer and use it in GitHub Desktop.
require 'activesupport/json_encoder'
class A
def initialize; @thing = "zoidberg"; end
def as_json(options={})
{
:whynot => @thing,
:this => "string"
}
end
end
class B
def initialize; @obja = A.new; end
def as_json(options={})
{
:obja => @obja
}
end
end
# Works
puts B.new.to_json
# Doesn't work
puts JSON.pretty_generate(B.new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment