Kotlin – Convert Object to/from XML File (XML String) by Jackson

In the tutorial, we will show how to convert XML String/File to Object and versus by Kotlin language with Jackson.

Jackson XML Dataformat

For serialize/deserialize Object to XML and versus, we use ‘Jackson Dataformat XML’ dependency:

Write Kotlin object to XML

Create model:

Kotlin object to XML String

Use writeValueAsString(obj: Object): String:

Kotlin object to XML File

Use writeValue(File resultFile, Object value): Unit:

Program – Kotlin object to XML

Convert XML to Kotlin object

XML String to Kotlin object

Use readValue(content: String, valueType: Class<*>):

XML File to Kotlin object

Use readValue(src: File, valueType: Class<*>):

Program – XML to Kotlin object

By grokonez | March 10, 2018.

Last updated on February 6, 2020.

Related Posts

1 thought on “Kotlin – Convert Object to/from XML File (XML String) by Jackson”

Got Something To Say:

Your email address will not be published. Required fields are marked *