Yet another Typesafe config Scala wrapper powered by circe
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
project Update sbt-release to 1.0.10 Nov 6, 2018
src Remove unused type parameter from Parser.toJson Feb 19, 2018
.gitignore Initial import Jan 25, 2017
.travis.yml Update Scala 2.12 version Sep 28, 2018
CONTRIBUTING.md Update the contributor's guide Aug 23, 2017
LICENSE
NEWS.md Update docs and MiMa for version 0.5.0 Sep 29, 2018
README.md Update docs and MiMa for version 0.5.0 Sep 29, 2018
build.sbt Update discipline to 0.10.0 (#23) Nov 7, 2018

README.md

circe-config

Travis CI Status Latest Version Badge

Small library for translating between HOCON, Java properties, and JSON documents and circe's JSON AST.

At a high-level it can be used as a circe powered front-end for the Typesafe config library to enable boilerplate free loading of settings into Scala types. More generally it provides parsers and printers for interoperating with Typesafe config's JSON AST.

Usage

To use this library configure your sbt project with the following line:

libraryDependencies += "io.circe" %% "circe-config" % "0.5.0"

Documentation

Example

scala> import com.typesafe.config.{ ConfigFactory, ConfigMemorySize }
scala> import io.circe.generic.auto._
scala> import io.circe.config.syntax._
scala> import scala.concurrent.duration.FiniteDuration

scala> case class ServerSettings(host: String, port: Int, timeout: FiniteDuration, maxUpload: ConfigMemorySize)
scala> case class HttpSettings(server: ServerSettings, version: Option[Double])
scala> case class AppSettings(http: HttpSettings)

scala> val config = ConfigFactory.load()

scala> config.as[ServerSettings]("http.server")
res0: Either[io.circe.Error,ServerSettings] = Right(ServerSettings(localhost,8080,5 seconds,ConfigMemorySize(5242880)))

scala> config.as[HttpSettings]("http")
res1: Either[io.circe.Error,HttpSettings] = Right(HttpSettings(ServerSettings(localhost,8080,5 seconds,ConfigMemorySize(5242880)),Some(1.1)))

scala> config.as[AppSettings]
res2: Either[io.circe.Error,AppSettings] = Right(AppSettings(HttpSettings(ServerSettings(localhost,8080,5 seconds,ConfigMemorySize(5242880)),Some(1.1))))

Based on this application.conf.

Contributing

Contributions are very welcome. Please see instructions on how to create issues and submit patches.

Releasing

To release version x.y.z run:

> sbt -Dproject.version=x.y.z release

License

circe-config is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.