I think this is incorrect. If the object responds to `to_xml`, why would you first convert it to JSON?