toJson
Serializes a Kotlin type into its equivalent Json representation.
Example:
override fun toJson(writer: JsonWriter, customScalarAdapters: CustomScalarAdapters, value: LocalDateTime) {
writer.value(value.toString())
}
Content copied to clipboard
Alternatively, you can use the built-in AnyAdapter:
override fun toJson(writer: JsonWriter, customScalarAdapters: CustomScalarAdapters, value: GeoPoint) {
val map = mapOf("lat" to value.lat, "lon" to value.lon)
AnyAdapter.toJson(writer, map)
}
Content copied to clipboard