Created
January 23, 2015 16:25
-
-
Save Filirom1/7da2055d08da92e6b64e to your computer and use it in GitHub Desktop.
xml2json with base64 decoding
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 "rubygems" | |
require "crack" | |
require "json" | |
require "base64" | |
myXML = Crack::XML.parse(File.read(ARGV[0])) | |
def decode_base64(parent, myHash) | |
myHash.each {|key, value| | |
if value.is_a?(Hash) | |
decode_base64(key, value) | |
elsif value.is_a? String and value.include? "__base64__" | |
value.slice!("__base64__") | |
myHash[key] = Base64.decode64(value) | |
end | |
} | |
end | |
decode_base64(nil, myXML) | |
print JSON.pretty_generate(myXML) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment