What's the recommended practice to build a `descri...
# serialization
s
What's the recommended practice to build a
descriptor
for a serializer that can deserialize from either a string or object? I was previously using
buildSerialDescriptor(serialName, SerialKind.CONTEXTUAL) { ... }
but I just learned from its docs that its use is discouraged in favor of
buildClassSerialDescriptor
, but that doe snot allow me to declare that the deserializer is contextual...
e
Copy code
SerialDescriptor(serialName, serialDescriptor<JsonElement>())
s
Isn't
JsonElement
too generic to be meaningful? I mean, the point of the descriptor is to describe the typed structure.
Anyway, I believe I mixed up terms here, as a (de-)serializer than can deserialize from different syntaxes is not what KxS calls "contextual".
And IIUC, for the descriptor it does not matter how the input is shaped, but only what the target to deserialize looks like.
e
if you're consuming either a string or an object, then that isn't a typed structure that can be represented in any of kxs's formats other than Json