Created
September 7, 2023 00:30
-
-
Save mkasberg/ef242a9d1b24a87af965745e717b6855 to your computer and use it in GitHub Desktop.
Boilerplate to parse a JSON file in Ruby
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
#!/usr/bin/env ruby | |
require 'json' | |
if ARGV[0].nil? | |
puts 'Usage: parse_json.rb FILENAME.json' | |
exit 1 | |
end | |
data = JSON.load_file(ARGV[0], symbolize_names: true) | |
puts JSON.pretty_generate(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment