I have the following ``` "classificationIte...
# serialization
e
I have the following
Copy code
"classificationItems": [
            {
                "classificationItem": {
                    "classificationItemId": {
                        "guid": "DAA21B11-88B9-4897-A12E-44CD2E3D07CD"
                    },
                    "id": "Site",
                    "name": "",
                    "description": "",
                    "children": [
                        {
                            "classificationItem": {
                                ...
                            }
                        },
                        ...
                    ]
                }
            },
            ...
        ]
where
classificationItems
is a list of ClassificationItem wrappers I'd like to get rid of that wrapper and have
classicationItems
a direct list of `ClassificationItems`(and so the children), so I created my own DeserializationStrategy However I'd still like to avoid manual job and take advantage of automatic parsing when it comes to the
classificationItem
object/class, how can I do that?
my serializer so far
Copy code
val d = object : DeserializationStrategy<Array<ClassificationItem>> {
            override val descriptor: SerialDescriptor = listSerialDescriptor<ClassificationItem>()
            override fun deserialize(decoder: Decoder): Array<ClassificationItem> =
                decoder.decodeStructure(descriptor) {
                    TODO()
                }
        }
I can see the values in
decoder
, but I have no idea how to access them
maybe I got it
decoder as JsonDecoder
it works partially, because it fails when it tries to parse the children, which are wrapped as well
got it, custom serializer on prop
Copy code
@Serializable(with = ClassificationItemListSerializer::class)
val children: List<ClassificationItem> = emptyList()