def collectionJson[T, C <: Iterable[T]]()

in bijection-json/src/main/scala-2.13+/com/twitter/bijection/json/CollectionJson.scala [29:55]


  def collectionJson[T, C <: Iterable[T]](implicit
      fact: Factory[T, C],
      jbij: JsonNodeInjection[T]
  ): JsonNodeInjection[C] =
    new AbstractJsonNodeInjection[C] {
      def apply(l: C) = {
        val ary = JsonNodeFactory.instance.arrayNode
        l foreach { t =>
          ary.add(jbij(t))
        }
        ary
      }
      override def invert(n: JsonNode): Try[C] = {
        val builder = fact.newBuilder
        var inCount = 0
        n.getElements.asScala.foreach { jn =>
          inCount += 1
          val thisC = jbij.invert(jn)
          if (thisC.isFailure) {
            return InversionFailure.failedAttempt(n)
          }
          builder += thisC.get
        }
        val res = builder.result
        if (res.size == inCount) Success(res) else InversionFailure.failedAttempt(n)
      }
    }