How can I convert JSON to XML in Ruby?

前端 未结 4 1579
有刺的猬
有刺的猬 2021-02-20 18:28

Is there any way to convert JSON to XML in Ruby?

4条回答
  •  借酒劲吻你
    2021-02-20 19:11

    i don't know a magic gem to do it, but what you can do easily is xml to hash and hash to json.

    require 'active_support'
    my_hash = Hash.from_xml(my_xml)
    

    then

    require 'json'
    my_json = my_hash.to_json
    

提交回复
热议问题