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 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).

  • parser
  • printer
  • syntax

object printer

Print io.circe.Json to a Typesafe Config string.

Source
printer.scala
Example:
  1. scala> import io.circe.Json
    scala> import io.circe.config.printer
    
    scala> val options = printer.DefaultOptions.setFormatted(false)
    scala> val json = Json.obj("server" -> Json.obj("host" -> Json.fromString("localhost"), "port" -> Json.fromInt(8080)))
    scala> printer.print(json, options)
    res0: String = server{host=localhost,port=8080}
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. printer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val DefaultOptions: ConfigRenderOptions

    Default printer options.

    Default printer options.

    By default JSON is printed in HOCON format without origin comments.

    See also

    com.typesafe.config.ConfigRenderOptions

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. def print(root: Json, options: ConfigRenderOptions = DefaultOptions): String

    Print JSON to a Typesafe Config string.

    Print JSON to a Typesafe Config string.

    root

    A JSON object

    options

    Printer options allowing to configure printing to JSON or HOCON

  17. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  18. def toString(): String
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  20. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped