Skip to content

Instantly share code, notes, and snippets.

@vasile
Created December 30, 2015 08:33
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 vasile/6be83fb48dc67a1bb435 to your computer and use it in GitHub Desktop.
Save vasile/6be83fb48dc67a1bb435 to your computer and use it in GitHub Desktop.
Beautify JSONs
require 'json'
if ARGV[0].nil?
print "USAGE: json_beauty.rb /path/tofile.json\n"
exit
end
json_path = ARGV[0]
json = JSON.parse(File.open(json_path, "r").read)
if json.nil?
print "Invalid input JSON !\n"
exit
end
File.open(json_path, "w") {|f| f.write(JSON.pretty_generate(json)) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment