Created
December 30, 2015 08:33
-
-
Save vasile/6be83fb48dc67a1bb435 to your computer and use it in GitHub Desktop.
Beautify JSONs
This file contains 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
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