dave08
01/16/2023, 4:57 PMMap<String, Map<String, Any>>
where Any
can be one of String
, Set<String>
or Map<String, String>
? I don't mind if instead of Any
I'd have a sealed interface AnyValue
with wrappers for those options... although I'd maybe prefer a value class
that could have my own helper functions to cast and retreive one of those... I would know in advance which one it is using the String
key in the inner map...Adam S
01/16/2023, 6:40 PMdave08
01/17/2023, 1:08 PMAdam S
01/17/2023, 2:11 PMsealed interface AnyValue
then you could use value classes for the String
, Set<String>
, Map<String, String>
- then you would have your own type hierarchy. If the value classes were @Serializable
then the plugin-generated serializers would work just fine.
The slightly tricky bit would be writing the KSerializer for AnyValue
. It wouldn’t be too hard if you used the JsonPolymorphicSerializer
(or whatever the real name is) provided by KxS.dave08
01/17/2023, 2:13 PMAdam S
01/17/2023, 2:14 PMException in thread "main" java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
I’ve made an issue: https://github.com/Kotlin/kotlinx.serialization/issues/2159dave08
01/17/2023, 3:05 PMAdam S
01/17/2023, 3:06 PMdave08
01/17/2023, 3:07 PMAdam S
01/17/2023, 3:15 PM