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

morphir.sdk.dict.Codec.scala Maven / Gradle / Ivy

The newest version!
package morphir.sdk.dict

import io.circe.{ Decoder, Encoder }
import morphir.sdk.Dict
import morphir.sdk.Dict.Dict

object Codec {

  implicit def decodeDict[K, V](implicit decodeKey: Decoder[K], decodeValue: Decoder[V]): Decoder[Dict[K, V]] =
    Decoder.decodeList(Decoder.decodeTuple2(decodeKey, decodeValue)).map(Dict.fromList)

  implicit def encodeDict[K, V](implicit encodeKey: Encoder[K], encodeValue: Encoder[V]): Encoder[Dict[K, V]] =
    Encoder.encodeList(Encoder.encodeTuple2(encodeKey, encodeValue)).contramap(Dict.toList)

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy