Convert Scala Object to XML

There are many Scala libraries for converting arbitrary objects to JSON and several for converting JSON to XML, but I cannot find a good way to convert arbitrary objects to XML. What is a good approach?

+6
source share
2 answers

I used scalaxb a while ago. It works very well if you have XSD (or WSDL) as input to create your classes. If so, I also recommend using it.

Since you are also talking about JSON, perhaps you have a web application using REST. In this case, see Raise REST Support . For example, if you use one of your internal systems of constant persistence, then all your entity types get a free toXML method.

A third possibility would be to write your own transformation using Scala XML literals .

Btw possible duplicates when stack overflows: Scala XML Serialization and What is the XML serialization library for Scala?

+3
source

scalaxb looks decent, I would try this first.

0
source

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


All Articles