-
-
Save neerajsingh0101/379298 to your computer and use it in GitHub Desktop.
to_xml agreement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> [User.first, User.last].to_xml | |
# master branch | |
<users type="array"> | |
<user> | |
<name>John</name> | |
</user> | |
<user> | |
<name>Mary</name> | |
</user> | |
</users> | |
# my patch branch | |
<objects type="array"> | |
<object> | |
<name>raj1</name> | |
<data type="yaml" nil="true"></data> | |
<id type="integer">1</id> | |
</object> | |
<object> | |
<name>raj2</name> | |
<data type="yaml" nil="true"></data> | |
<id type="integer">2</id> | |
</object> | |
</objects> | |
# note that last item is User class | |
a = [10, [20, 30, ["helo", "world"]], [1.2, 1.3], {:foo => :bar}, User] | |
puts a.to_xml | |
<?xml version="1.0" encoding="UTF-8"?> | |
<objects type="array"> | |
<object type="integer">10</object> | |
<object type="array"> | |
<object type="integer">20</object> | |
<object type="integer">30</object> | |
<object type="array"> | |
<object>helo</object> | |
<object>world</object> | |
</object> | |
</object> | |
<object type="array"> | |
<object type="float">1.2</object> | |
<object type="float">1.3</object> | |
</object> | |
<object> | |
<foo type="symbol">bar</foo> | |
</object> | |
<object>User</object> | |
</objects> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment