Is there a way to change what the class discrimina...
# serialization
a
Is there a way to change what the class discriminator field will contain ? I want to add a prefix to it for a very specific purpose
e
Do you have an example what you want to achieve or what your json looks like?
a
Copy code
[
	{
		"type": "minecraft:block",
		"result_state": {
			"Name": "minecraft:stone"
		}
	},
	{
		"type": "minecraft:bandlands"
	},
	{
		"type": "minecraft:condition",
		"if_true": {
			"type": "minecraft:biome",
			"biome_is": []
		},
		"then_run": {
			"type": "minecraft:block",
			"result_state": {
				"Name": "minecraft:stone"
			}
		}
	}
]
For example, where I want to customise the class discriminator so that it is written as
"minecraft:${value::class.simpleName.lowercase()}"
e
I would just use '@SerialName("minecraft:block")' on top of classes
a
Yes I know that would work, but I have to apply this to like 200 classes, but it uses around 30 sealed interfaces which is much less, so if I can only apply a custom serializer or anything else to these sealed interfaces, it would be simpler for me
e
Then write custom serializer
a
Then how do I create a serializer that will work for any sealed interface ? 🤔
e
Do they have a common parent class? Or you can add annotation to every place with specification of serialiser or use contextual
a
Nope they don't have a common parent, I could add one but I'm unsure if it would be the best solution