Created
October 18, 2013 03:28
-
-
Save Altech/7036087 to your computer and use it in GitHub Desktop.
modify json interactively on Ruby data structure.
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 | |
def modify_json(file_path) | |
require 'json' | |
require 'colorize' | |
require 'pry' | |
raise "The file is not exist!".red if not File.exists? file_path | |
json = JSON.parse(File.read(file_path)) | |
puts "json.keys: " + json.keys.join(",") | |
binding.pry | |
File.write file_path, json.to_json | |
puts "The file has updated!".green | |
end | |
modify_json(ARGV.first) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment