Over a million developers have joined DZone.

Convert XML To JSON Using Ruby And ActiveSupport

·
// Convert XML to JSON using Ruby and ActiveSupport


#! /usr/bin/env ruby

require 'rubygems'
require 'active_support/core_ext'
require 'json'

xml = File.open(ARGV.first).read
json = Hash.from_xml(xml).to_json

File.open(ARGV.last, 'w+').write json
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}