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

org.json4s.DefaultReaders0.scala Maven / Gradle / Ivy

The newest version!
package org.json4s

import scala.collection.generic.CanBuildFrom

private[json4s] trait DefaultReaders0 {
  implicit def iterableReader[F[_], V](implicit cbf: CanBuildFrom[F[_], V, F[V]], valueReader: Reader[V]): Reader[F[V]] =
    new Reader[F[V]] {
      def read(value: JValue): F[V] = value match {
        case JArray(items) =>
          val builder = cbf()
          items.foldLeft(builder) { (acc, i) => acc += valueReader.read(i); acc}.result()
        case x =>
          throw new MappingException("Can't convert %s to Iterable." format x)
      }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy