Translate simple XML to JSON

I need the JSON equavalent of the following XML please

<Farms>
      <Farm>
            <Name>Farm1</Name>
            <Description>Description1</Description>
            <Country>Japan</Country>
            <Size>210</Size>
            <Schedule>
                  <Date>01/12/2015</Date>
            </Schedule>
      </Farm>
      <Farm>
            <Name>Farm2</Name>
            <Description>Description2</Description>
            <Country>Canada</Country>
            <Size>550</Size>
            <Schedule>
                  <Date>17/06/2016</Date>
            </Schedule>
      </Farm>      
</Farms>
LVL 12
gbzhhuAsked:
Who is Participating?
 
neubdaCommented:
{"Farms":{"Farm":[{"Name":"Farm1","Description":"Description1","Country":"Japan","Size":"210","Schedule":{"Date":"01/12/2015"}},{"Name":"Farm2","Description":"Description2","Country":"Canada","Size":"550","Schedule":{"Date":"17/06/2016"}}]}}

I used this ruby snipped:

require 'json'
require 'active_support/core_ext/hash'

xmlinput = IO.read('foo.xml')
puts Hash.from_xml(xmlinput).to_json
0
 
gbzhhuAuthor Commented:
Many thanks for the quick response.  There are many converters I didn't know.  Only now I googled and found :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.