# Change attribute names in serialized output - to\_xml or to\_json

**URL:** <https://www.ruby-forum.com/t/change-attribute-names-in-serialized-output-to-xml-or-to-json/156665>\
**Category:** Rails\
**Created:** [December 31, 2008, 4:56pm UTC](https://www.ruby-forum.com/t/change-attribute-names-in-serialized-output-to-xml-or-to-json/156665 "2008-12-31T16:56:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [December 31, 2008, 4:56pm UTC](https://www.ruby-forum.com/t/change-attribute-names-in-serialized-output-to-xml-or-to-json/156665/1 "2008-12-31T16:56:16Z")

</div>

When serializing an object, is there a way to change the name of an  
attribute outputted without changing the underlying model (i.e… I do  
not want to change model attributes or methods? I have a class that  
has an association called materials… I would like the tag generated  
when I call to\_xml to be vs . Another example  
is I have a method called get\_url… I would like the tag to be   
vs \<get\_url\>…
