Skip to content

Instantly share code, notes, and snippets.

@mkasberg
Created September 7, 2023 00:30
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 mkasberg/ef242a9d1b24a87af965745e717b6855 to your computer and use it in GitHub Desktop.
Save mkasberg/ef242a9d1b24a87af965745e717b6855 to your computer and use it in GitHub Desktop.
Boilerplate to parse a JSON file in Ruby
#!/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