Skip to content

Instantly share code, notes, and snippets.

@pocke
Last active August 29, 2015 14:27
Show Gist options
  • Save pocke/c7747da73d79ecde4dad to your computer and use it in GitHub Desktop.
Save pocke/c7747da73d79ecde4dad to your computer and use it in GitHub Desktop.
json parser
module J
module_function
def parse(j);eval(j) end
def null;nil end
end
p J.parse(STDIN.read)
{
"foo": {
"bar": "hoge",
"foobar": [1,2,3]
},
"piyo": null,
"poyo": 10e7,
"pu-yo": -1
}
@pocke
Copy link
Author

pocke commented Aug 11, 2015

$ ruby j.rb <test.json
# => {:foo=>{:bar=>"hoge", :foobar=>[1, 2, 3]}, :piyo=>nil, :poyo=>100000000.0, :"pu-yo"=>-1}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment