Report abuse

XML

  <entry>
    <string>openwire</string>
    <string>tcp://localhost.localdomain:6166</string>
  </entry>
  <entry>
    <string>storeLimit</string>
    <long>1073741824</long>
  </entry>

From JSON

{"map"=>
  [{"entry"=>
      {"long"=>1073741824, "string"=>"storeLimit"},
      {"string"=>["openwire", "tcp://localhost.localdomain:6166"]}]}]} 


Why isnt the 2nd:

{"string"=>"openwire", "string"=> "tcp://localhost.localdomain:6166"}

XML Parser

def amqxmldecode(amqmap)
    map = Hash.new

    Document.new(amqmap).root.each_element do |element|
        value = name = nil

        element.each_element_with_text do |e,t|
            name = e.text unless name

            if name
                case e.name
                    when "string"
                        map[name] = e.text

                    when /int|long/
                        map[name] = e.text.to_i

                    when "double"
                        map[name] = e.text.to_f

                    else
                        raise("Unknown data type #{e.name}")
                end
            end
        end
    end

    map
end