house9

random code and what not

Save a ruby hash as a json file

| Comments

Save a ruby hash as a json file

I have found the following technique useful when debugging json structures generated from ruby hashes.

1
2
3
4
5
6
some_json = {
  some_attribute: 'SOME_DATA'
}


IO.write "tmp/some_json-#{SecureRandom.hex(2)}.json", JSON.pretty_generate(some_json)

Comments