gaetan
11/07/2023, 7:24 AMmbonnin
11/07/2023, 8:19 AMJSON
custom scalars are transmitted like so:
{
"data": {
"jsonField": {
"key": "value"
}
}
}
AnyAdapter
to map it to a Kotlin Any
that you can cast to Map<String, Any?>
{
"data": {
"jsonField": "{ \"key\": \"value\" }"
}
}
(less common)StringAdapter
to map it to a Kotlin String
AnyAdapter
or StringAdapter
because the runtime will do this by default and present you with an Any
type that you can either cast to a Map
or String
Map
back to JSON, you can use something like so:
buildJsonString {
AnyAdapter.toJson(this, CustomScalarAdapters.Empty, map)
}
gaetan
11/07/2023, 9:53 AM