Rails XML generation as an Active Serializer model

Is there a way to generate XML from the configuration / programming used by the Rails AciveModelSerializer gem? It seems that AMS only generates custom JSON. XML comes in the default format.

I saw links to AciveModelSerialization and that it supports JSON and XML, but the configuration, while similar, is different. What is the story with the difference between the two? Is one leaving? How are they compared in real use (other than formatting)?

+4
source share
1 answer

As you can see here , there (and elsewhere), XML is slowly disappearing from the Internet. There are several reasons for this. 1 - JSON objects are smaller. 2 - JSON is the de facto format for most client javascript libraries. 3 - Fashion, people like it.

You can still use ActiveModel to serialize Xml if you want:

http://api.rubyonrails.org/classes/ActiveModel/Serializers/Xml.html

Hope this helps.

0
source

Source: https://habr.com/ru/post/1524193/


All Articles