codecs.basic.SequenceJSONCodec.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluid-json-coding Show documentation
Show all versions of fluid-json-coding Show documentation
A JSON library written in pure Kotlin (coding extension)
package com.github.fluidsonic.fluid.json
object SequenceJSONCodec : AbstractJSONCodec, JSONCodingContext>() {
override fun JSONDecoder.decode(valueType: JSONCodingType>): Sequence<*> {
val elementType = valueType.arguments.single()
return readListByElement {
readValueOfTypeOrNull(elementType)
}.asSequence()
}
override fun JSONEncoder.encode(value: Sequence<*>) =
writeList(value)
val nonRecursive = NonRecursiveJSONCodec.create>()
}