Skip to content

Instantly share code, notes, and snippets.

@palon7
Created February 6, 2021 07:41
Show Gist options
  • Save palon7/5aed2f628ea7ccbf7e9f30733b0164ab to your computer and use it in GitHub Desktop.
Save palon7/5aed2f628ea7ccbf7e9f30733b0164ab to your computer and use it in GitHub Desktop.
Convert old SynthesizerV dictionary(.xml) to new format(.json)
require "rexml/document"
require "pp"
require 'json'
filename = ARGV[0]
abort("Usage: ./#{File.basename($0)} <dictionary_xml>") if filename.nil?
doc = REXML::Document.new(File.new(filename))
json = {}
json["data"] = []
doc.elements.each("PROPERTIES/VALUE") do |v|
json["data"].push({
"w" => v.attributes["name"],
"p" => v.attributes["val"]
})
end
output_filename = File.basename(filename, '.*') + ".json"
File.open(output_filename, mode = "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