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

io.circe.RootEncoder.scala Maven / Gradle / Ivy

There is a newer version: 0.9.3
Show newest version
package io.circe

import io.circe.export.Exported

/**
 * A subtype of `Encoder` that statically verifies that the instance encodes
 * either a JSON array or an object.
 *
 * @author Travis Brown
 */
trait RootEncoder[A] extends Encoder[A]

final object RootEncoder extends LowPriorityRootEncoders {
  /**
   * Return an instance for a given type.
   *
   * @group Utilities
   */
  final def apply[A](implicit instance: RootEncoder[A]): RootEncoder[A] = instance
}

private[circe] trait LowPriorityRootEncoders {
  implicit final def importedRootEncoder[A](implicit exported: Exported[ObjectEncoder[A]]): RootEncoder[A] =
    exported.instance
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy