From: Brian Candler Date: 2010-04-08T00:38:27+09:00 Subject: Re: xml to ruby compactible json Smp Mp wrote: > I use the below code : > > data=Hash.from_xml(xml).to_json() > > where xml contains the xml data. > i get the result in the below format : > > {'responseHeader':{'status':0,'QTime':0}} That looks like valid JSON to me. > but i require the result as : > { > 'responseHeader'=>{ > 'status'=>0, > 'QTime'=>0} > } That's not valid JSON. You mean you want a Ruby Hash? Try data = Hash.from_xml(xml) (there's no point converting it into JSON if you're going to JSON.parse it back into a hash) -- Posted via http://www.ruby-forum.com/.