All Downloads are FREE. Search and download functionalities are using the official Maven repository.

codecs.basic.MapJSONCodec.kt Maven / Gradle / Ivy

There is a newer version: 0.9.24
Show newest version
package com.github.fluidsonic.fluid.json


object MapJSONCodec : AbstractJSONCodec, JSONCodingContext>() {

	override fun JSONDecoder.decode(valueType: JSONCodingType>): Map<*, *> {
		val (elementKeyType, elementValueType) = valueType.arguments

		return readMapByElement {
			readValueOfTypeOrNull(elementKeyType) to readValueOfTypeOrNull(elementValueType)
		}
	}


	override fun JSONEncoder.encode(value: Map<*, *>) =
		writeMap(value)


	val nonRecursive = NonRecursiveJSONCodec.create>()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy