TomlBlockArray

@SerialInfo
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class TomlBlockArray(val itemsPerLine: Int = 1)(source)

Modifies the encoding process of corresponding array-like property, either to force array of table to be encoded as block array, or to change how many items should be encoded per line (this will override the default config).

Note that, if the annotated property is also marked with TomlInline, this annotation will not take effect.

class NullablePairList<F, S>(
@TomlBlockArray(2)
val list: List<Pair<F, S>?>
)
NullablePairList(listOf(Pair("key", 1), null, Pair("key", 3), Pair("key", 4)))

will produce:

list = [
{ first = "key", second = 1 }, null,
{ first = "key", second = 3 }, { first = "key", second = 4 }
]

Properties

Link copied to clipboard
val itemsPerLine: Int = 1