name Root Classes
Specifies whether classes serialized as the root NBT tag should be named with their serial name. true
by default.
Specifically, a named tag is represented as a single entry in an NBT compound. Encoding root classes with names will nest them into a NBT compound using the serial name for the entry. This applies to serializers with StructureKind.CLASS and the default polymorphic serializers.
For example, based on the NBT spec's test.nbt
file:
@Serializable
@SerialName("hello world")
class Test(val name: String)
val test = Test(name = "Bananarama")
// Encoding `test` with naming root classes:
// {"hello world":{name:"Bananarama"}}
// Encoding `test` without naming root classes:
// {name:"Bananarama"}
Content copied to clipboard