I'd need to serialize an object with multiple cust...
# serialization
e
I'd need to serialize an object with multiple custom/dynamic fields
Copy code
"addOnCommandParameters": {
            "myAddOnCommandParameter1": "X=?"
        }
what's the best strategy in this case? A custom serializer? If yes, how is gonna be the descriptor?
e
If it's always String -> String you could just use a Map<String, String> to represent it
e
yeah, I presume, but I wouldn't be sure the return example is actually an int, to say
maybe <String, any>?
e
with coerceInputTypes I think a Int could be automatically wrapped into String
Using Any is tricky/impossible.. you would need some marker to figure out what type the field is..
e
uhm, ok, then <String, String>, shall I use
mapSerialDescriptor
then?
e
Do you need a custom descriptor?
Copy code
@Serializable
data class Command(
  val addOnCommandParameters: Map<String,String>
)
Should be enough
e
yeah, shame I couldn't get that myself thanks!