XML to JSON conversion

Hello, Im trying to convert a simple XML structure into a JSON object, not able to find out proper way to do it, tried JSON::BUilder but not workign correctly

want to turn this into a JSON or Hash structure

<monit id="c943df6b60bd5e0e807eeb950e7929fa" incarnation="1700966803" version="5.31.0">
  <server>
    <uptime>71885</uptime>
    <poll>5</poll>
    <startdelay>0</startdelay>
    <localhostname>mrxvivo</localhostname>
    <controlfile>/home/mreider/dev/crystal/monitbee/monit.conf</controlfile>
    <httpd>
      <address>127.0.0.1</address>
      <port>19841</port>
      <ssl>0</ssl>
    </httpd>
  </server>
</monit>

thanks

found a lib that does this nicely

https://github.com/mamantoha/xml_converter

3 Likes