Lev Teytelman03/23/2023, 4:21 AM
Of course, I don't want recursive Tags/SavedFiles in my serialization, as that would lead to infinite loops; I only serialize the names (all my custom serializers do is extract names). When I use
@Serializable data class Tag( val name: String, @Serializable(with = TagStringSerializer::class) val parent: Tag? = null, val subTags: MutableSet<@Serializable(with = TagStringSerializer::class) Tag> = ConcurrentSet(), val files: MutableSet<@Serializable(with = SavedFileStringSerializer::class) SavedFile> = ConcurrentSet() ) @Serializable data class SavedFile( @Serializable(with = FileSerializer::class) val file: File, val tags: MutableSet<@Serializable(with = TagStringSerializer::class) Tag> = ConcurrentSet() )
, this works properly and sends
. However, when I do
, I receive an array of default-serialized tags instead of just the names, as if it's ignoring the annotation in the set:
. Even stranger, when I do just
, it works just fine and gives me a properly-encoded array
. Of course, I could just create a function like
and wrap a call to
, but this seems hacky and non-ideal. I'm just very confused as to why the two functions are behaving differently and how I can fix the serialization done within
Aleksei Tirman [JB]03/23/2023, 10:50 AM
Lev Teytelman03/24/2023, 7:21 PM
to run it) Requesting
returns the properly serialized object, but requesting
returns the children with default serialization, despite them being in a set with a specific serialization set. Moreover, requesting
returns the proper string array and not an array of objects.
work properly? I'm worried that I will build my application around one behavior and suddenly begin to encounter another.
Aleksei Tirman [JB]03/28/2023, 8:34 AM
method from the reflection package to pass a type info to the
plugin, I guess it loses the information about the serializer.