Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'active_support'
Hash.from_xml('
<projects page="1" per_page="3" type="array">
<project>
<name>project 1</name>
</project>
<project>
<name>project 2</name>
</project>
<project>
<name>project 3</name>
</project>
</projects>
')
# => {"projects"=>[{"name"=>"project 1"}, {"name"=>"project 2"}, {"name"=>"project 3"}]}
Hash.from_xml('
<projects page="1" per_page="3">
<project>
<name>project 1</name>
</project>
<project>
<name>project 2</name>
</project>
<project>
<name>project 3</name>
</project>
</projects>
')
# => {"projects"=>{"project"=>[{"name"=>"project 1"}, {"name"=>"project 2"}, {"name"=>"project 3"}], "per_page"=>"3", "page"=>"1"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment