Packages

  • package root
    Definition Classes
    root
  • package io
    Definition Classes
    root
  • package circe
    Definition Classes
    io
  • package config

    circe-config: A Typesafe config wrapper powered by circe.

    circe-config: A Typesafe config wrapper powered by circe.

    Definition Classes
    circe
    Example:
    1. scala> import cats.effect.unsafe.implicits.global
      scala> import com.typesafe.config.ConfigFactory
      scala> import io.circe.generic.auto._
      scala> import io.circe.config.syntax._
      
      scala> case class ServerSettings(host: String, port: Int, ssl: Option[String])
      scala> case class HttpSettings(server: ServerSettings, version: Double)
      scala> case class AppSettings(http: HttpSettings)
      
      scala> val config = ConfigFactory.parseString("http { version = 1.1, server { host = localhost, port = 8080 } }")
      
      scala> config.as[ServerSettings]("http.server")
      res0: Either[io.circe.Error, ServerSettings] = Right(ServerSettings(localhost,8080,None))
      
      scala> config.as[HttpSettings]("http")
      res1: Either[io.circe.Error, HttpSettings] = Right(HttpSettings(ServerSettings(localhost,8080,None),1.1))
      
      scala> config.as[AppSettings]
      res2: Either[io.circe.Error, AppSettings] = Right(AppSettings(HttpSettings(ServerSettings(localhost,8080,None),1.1)))
      
      scala> import cats.effect.IO
      scala> config.asF[IO, AppSettings]
      res3: IO[AppSettings] = IO(AppSettings(HttpSettings(ServerSettings(localhost,8080,None),1.1)))
      
      scala> import io.circe.config.parser
      scala> val settings = parser.decodeF[IO, AppSettings]()
      scala> settings.unsafeRunSync()
      res4: AppSettings = AppSettings(HttpSettings(ServerSettings(localhost,8080,None),1.1))
    Note

    Limitations for numerical types: Typesafe config uses Java's int, long and double types to represent numbers. In some cases, double values may be represented internally as long after a roundtrip since the HOCON formatting is not stable. Also, precision may be lost when converting from circe's JsonNumber to Typesafe config's number representation (as can be seen in the test for the printer laws).

  • object syntax

    Implicits for decoding Typesafe Config values and instances using circe decoders.

    Implicits for decoding Typesafe Config values and instances using circe decoders.

    In addition to syntax.durationDecoder and syntax.memorySizeDecoder for reading Typesafe Config specific value formats, this module also provides syntax.CirceConfigOps for decoding loaded configurations.

    Definition Classes
    config
    Example:
    1. scala> import io.circe.generic.auto._
      scala> import io.circe.config.syntax._
      scala> import scala.concurrent.duration.FiniteDuration
      scala> case class ServerSettings(port: Int, host: String, timeout: FiniteDuration)
      scala> val config = com.typesafe.config.ConfigFactory.parseString("port = 7357, host = localhost, timeout = 5 s")
      scala> config.as[ServerSettings]
      res0: Either[io.circe.Error, ServerSettings] = Right(ServerSettings(7357,localhost,5 seconds))
  • CirceConfigOps
c

io.circe.config.syntax

CirceConfigOps

implicit final class CirceConfigOps extends AnyVal

Enriches com.typesafe.config.Config instances with methods to decode to a specific type.

Source
syntax.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CirceConfigOps
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CirceConfigOps(config: Config)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. def as[A](path: String)(implicit arg0: Decoder[A]): Either[Error, A]

    Read config settings at given path into the specified type.

  5. def as[A](implicit arg0: Decoder[A]): Either[Error, A]

    Read config settings into the specified type.

  6. def asF[F[_], A](path: String)(implicit arg0: Decoder[A], ev: ApplicativeError[F, Throwable]): F[A]

    Read config settings at given path into the specified type.

  7. def asF[F[_], A](implicit arg0: Decoder[A], ev: ApplicativeError[F, Throwable]): F[A]

    Read config settings into the specified type.

  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. val config: Config
  10. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. def toString(): String
    Definition Classes
    Any

Inherited from AnyVal

Inherited from Any

Ungrouped