toJson

open override fun toJson(    writer: JsonWriter,     customScalarAdapters: CustomScalarAdapters,     value: List<T>)

Serializes a Kotlin type into its equivalent Json representation.

Example:

override fun toJson(writer: JsonWriter, customScalarAdapters: CustomScalarAdapters, value: Hero) {
writer.name("name")
writer.value(value.name)
writer.name("homeworld")
writer.value(value.homeworld)
}

Alternatively, you can use the built-in AnyAdapter:

override fun toJson(writer: JsonWriter, customScalarAdapters: CustomScalarAdapters, value: Hero) {
val map = mapOf("name" to value.name, "homeworld" to value.homeworld)
AnyAdapter.toJson(writer, customScalarAdapters, map)
}