Created
May 12, 2015 02:42
-
-
Save ybenjo/515809a0f405f834349f to your computer and use it in GitHub Desktop.
hoge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
class Hoge | |
def initialize | |
@a=1 | |
@b='hoge' | |
@c={:a => 1} | |
end | |
def to_json | |
h = { } | |
self.instance_variables.each do |v| | |
h[v] = self.instance_variable_get(v) | |
end | |
h.to_json | |
end | |
end | |
hoge = Hoge.new | |
p hoge.to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment