Hi folks,
is there any gem or code available for converting json data to xml data in ruby?
any help would be appreciated
Hi folks,
is there any gem or code available for converting json data to xml data in ruby?
any help would be appreciated
I think you can use the rexml library from standard library:
Thank you .let me try it out
I created a gem (the nam is Shale) to map XML, JSON or YAML to Ruby model and convert it between different formats, you may find it useful. A quick example:
require 'shale'
class Person < Shale::Mapper
attribute :name, Shale::Type::String
end
Person.from_json('{"name": "John Doe"}').to_xml
It will generate XML that looks like this (it’s customizable):
<person>
<name>John Doe</name>
</person>
Full docs are available at https://shalerb.org/
You can also use ActiveSupport. Here’s a script to convert JSON to XML using it: Active Support Core Extensions — Ruby on Rails Guides
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs