Skip to main content

Json

Maven Central

Writeopia comes with a plugin to allow serialization of information. It can be used to export information as json. You can add the library:

implementation("io.writeopia:writeopia-serialization:[version]")

This comes with a ready-to-go json implementation based on kotlinx-serialization-json. You can use it to have an already configured way to serialize Document and other data models of the SDK. This is a way to encode Document as a request in json:

private fun documentToJson(document: Document, json: Json = writeopiaJson): String {
val request = document.toApi().wrapInRequest()
return json.encodeToString(request)
}