object parser extends Parser
Utilities for parsing com.typesafe.config.Config sources to io.circe.Json as well as decoding to a specific type.
If you are working in something like cats.effect.IO, or some other type F[_] that provides a
cats.ApplicativeError, there're also decoders for loading such types.
- Source
- parser.scala
- scala> import com.typesafe.config.ConfigFactory scala> import io.circe.config.parser scala> val config = ConfigFactory.parseString("server { host = localhost, port = 8080 }") scala> val json: Either[io.circe.ParsingFailure, io.circe.Json] = parser.parse(config) scala> json.map(_.noSpaces).getOrElse("Parse failure") res0: String = {"server":{"port":8080,"host":"localhost"}} scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> case class AppSettings(server: ServerSettings) scala> parser.decode[AppSettings](config) res1: Either[io.circe.Error, AppSettings] = Right(AppSettings(ServerSettings(localhost,8080))) scala> parser.decodePath[ServerSettings](config, "server") res2: Either[io.circe.Error, ServerSettings] = Right(ServerSettings(localhost,8080)) scala> import cats.effect.IO scala> parser.decodePathF[IO, ServerSettings](config, "server") res3: cats.effect.IO[ServerSettings] = IO(ServerSettings(localhost,8080)) 
- See also
- syntax.configDecoder for how to map io.circe.Json to com.typesafe.config.Config 
- Alphabetic
- By Inheritance
- parser
- Parser
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
-   final  def !=(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def ##(): Int- Definition Classes
- AnyRef → Any
 
-   final  def ==(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def asInstanceOf[T0]: T0- Definition Classes
- Any
 
-    def clone(): AnyRef- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
 
-   final  def decode[A](config: Config)(implicit arg0: Decoder[A]): Either[Error, A]Load the default configuration and decode an instance at a specific path. Load the default configuration and decode an instance at a specific path. - scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> case class HttpSettings(server: ServerSettings) scala> case class AppSettings(http: HttpSettings) scala> import com.typesafe.config.ConfigFactory scala> val config = ConfigFactory.load() scala> parser.decode[AppSettings](config) res0: Either[io.circe.Error, AppSettings] = Right(AppSettings(HttpSettings(ServerSettings(localhost,8080)))) 
 Example:
-   final  def decode[A]()(implicit arg0: Decoder[A]): Either[Error, A]Load the default configuration and decode an instance at a specific path. Load the default configuration and decode an instance at a specific path. - scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> case class HttpSettings(server: ServerSettings) scala> case class AppSettings(http: HttpSettings) scala> parser.decode[AppSettings]() res0: Either[io.circe.Error, AppSettings] = Right(AppSettings(HttpSettings(ServerSettings(localhost,8080)))) 
 Example:
-   final  def decode[A](input: String)(implicit arg0: Decoder[A]): Either[Error, A]- Definition Classes
- Parser
 
-  final def decodeAccumulating[A](config: Config)(implicit arg0: Decoder[A]): ValidatedNel[Error, A]
-   final  def decodeAccumulating[A](input: String)(implicit arg0: Decoder[A]): ValidatedNel[Error, A]- Definition Classes
- Parser
 
-   final  def decodeF[F[_], A](config: Config)(implicit arg0: Decoder[A], ev: ApplicativeError[F, Throwable]): F[A]Decode an instance supporting cats.ApplicativeError. Decode an instance supporting cats.ApplicativeError. - scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> case class HttpSettings(server: ServerSettings) scala> case class AppSettings(http: HttpSettings) scala> import com.typesafe.config.ConfigFactory scala> val config = ConfigFactory.load() scala> import cats.effect.IO scala> parser.decodeF[IO, AppSettings](config) res0: cats.effect.IO[AppSettings] = IO(AppSettings(HttpSettings(ServerSettings(localhost,8080)))) 
 Example:
-   final  def decodeF[F[_], A]()(implicit arg0: Decoder[A], ev: ApplicativeError[F, Throwable]): F[A]Load default configuration and decode an instance supporting cats.ApplicativeError. Load default configuration and decode an instance supporting cats.ApplicativeError. - scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> case class HttpSettings(server: ServerSettings) scala> case class AppSettings(http: HttpSettings) scala> import cats.effect.IO scala> parser.decodeF[IO, AppSettings]() res0: cats.effect.IO[AppSettings] = IO(AppSettings(HttpSettings(ServerSettings(localhost,8080)))) 
 Example:
-   final  def decodeFile[A](file: File)(implicit arg0: Decoder[A]): Either[Error, A]Load configuration from file and decode an instance. Load configuration from file and decode an instance. - scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> case class HttpSettings(server: ServerSettings) scala> case class AppSettings(http: HttpSettings) scala> parser.decodeFile[AppSettings](new java.io.File("src/test/resources/application.conf")) res0: Either[io.circe.Error, AppSettings] = Right(AppSettings(HttpSettings(ServerSettings(localhost,8080)))) 
 Example:
-  final def decodeFileAccumulating[A](file: File)(implicit arg0: Decoder[A]): ValidatedNel[Error, A]
-   final  def decodePath[A](config: Config, path: String)(implicit arg0: Decoder[A]): Either[Error, A]Decode of an instance at a specific path. Decode of an instance at a specific path. - scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> import com.typesafe.config.ConfigFactory scala> val config = ConfigFactory.load() scala> parser.decodePath[ServerSettings](config, "http.server") res0: Either[io.circe.Error, ServerSettings] = Right(ServerSettings(localhost,8080)) 
 Example:
-   final  def decodePath[A](path: String)(implicit arg0: Decoder[A]): Either[Error, A]Load the default configuration and decode an instance. Load the default configuration and decode an instance. - scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> parser.decodePath[ServerSettings]("http.server") res0: Either[io.circe.Error, ServerSettings] = Right(ServerSettings(localhost,8080)) 
 Example:
-   final  def decodePathF[F[_], A](config: Config, path: String)(implicit arg0: Decoder[A], ev: ApplicativeError[F, Throwable]): F[A]Decode an instance supporting cats.ApplicativeError at a specific path. Decode an instance supporting cats.ApplicativeError at a specific path. - scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> import com.typesafe.config.ConfigFactory scala> val config = ConfigFactory.load() scala> import cats.effect.IO scala> import io.circe.config.parser scala> parser.decodePathF[IO, ServerSettings](config, "http.server") res0: cats.effect.IO[ServerSettings] = IO(ServerSettings(localhost,8080)) 
 Example:
-   final  def decodePathF[F[_], A](path: String)(implicit arg0: Decoder[A], ev: ApplicativeError[F, Throwable]): F[A]Load default configuration and decode an instance supporting cats.ApplicativeError at a specific path. Load default configuration and decode an instance supporting cats.ApplicativeError at a specific path. - scala> import io.circe.generic.auto._ scala> case class ServerSettings(host: String, port: Int) scala> import cats.effect.IO scala> parser.decodePathF[IO, ServerSettings]("http.server") res0: cats.effect.IO[ServerSettings] = IO(ServerSettings(localhost,8080)) 
 Example:
-   final  def eq(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-    def equals(arg0: AnyRef): Boolean- Definition Classes
- AnyRef → Any
 
-    def finalize(): Unit- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
 
-   final  def finishDecode[A](input: Either[ParsingFailure, Json])(implicit decoder: Decoder[A]): Either[Error, A]- Attributes
- protected[this]
- Definition Classes
- Parser
 
-   final  def finishDecodeAccumulating[A](input: Either[ParsingFailure, Json])(implicit decoder: Decoder[A]): ValidatedNel[Error, A]- Attributes
- protected[this]
- Definition Classes
- Parser
 
-   final  def getClass(): Class[_ <: AnyRef]- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-    def hashCode(): Int- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-   final  def isInstanceOf[T0]: Boolean- Definition Classes
- Any
 
-   final  def ne(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-   final  def notify(): Unit- Definition Classes
- AnyRef
- Annotations
- @native()
 
-   final  def notifyAll(): Unit- Definition Classes
- AnyRef
- Annotations
- @native()
 
-   final  def parse(input: String): Either[ParsingFailure, Json]- Definition Classes
- parser → Parser
 
-  final def parse(config: Config): Either[ParsingFailure, Json]
-  final def parse(): Either[ParsingFailure, Json]
-  final def parseFile(file: File): Either[ParsingFailure, Json]
-  final def parsePath(config: Config, path: String): Either[ParsingFailure, Json]
-  final def parsePath(path: String): Either[ParsingFailure, Json]
-   final  def synchronized[T0](arg0: => T0): T0- Definition Classes
- AnyRef
 
-    def toString(): String- Definition Classes
- AnyRef → Any
 
-   final  def wait(): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long, arg1: Int): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()