Last active
January 15, 2016 21:45
-
-
Save drakemccabe/3ec176ca71115bc40e2d to your computer and use it in GitHub Desktop.
Format JSON file
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
require "json" | |
require "pry" | |
file_raw = File.read("./keywords.json") | |
file = JSON.parse(file_raw) | |
counter = 1 | |
file["results"]["Keywords"].each_with_index do |keyword, index| | |
file["results"]["Keywords"][index] = { keyword["url"].split('/'[-1]).last => keyword } | |
end | |
File.open("./keywords1.json", "w") do |f| | |
f << (JSON.pretty_generate(file)) | |
end | |
file_raw = File.read("./keywords1.json") | |
file = JSON.parse(file_raw) | |
binding.pry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment