circe 0.7.0-M2
Pre-releaseThis milestone includes all features that are planned for 0.7.0—the only thing we're waiting on is the Cats 0.9.0 release (tracked here) and some more feedback from people who have tried out the milestones.
Printing to byte buffers
On the JVM, JSON printers now have a prettyByteString
method that allows printing a Json
value directly to a byte buffer (#535 and #537). This addition is designed to support "string-less encoding" in Finch, and will be accompanied by an equivalent method in circe-jackson.
Thanks to Vladimir Kostyukov and @imliar for driving and helping with these ByteBuffer
-related additions.
Kicking some modules out of the nest
Three modules have been moved to their own repositories in the circe organization:
Among other things, these moves have allowed us to simplify the build by scrapping sbt-doge and to publish circe-jackson artifacts for multiple Jackson versions.
This does mean that there will be a delay between the publication of the modules in this repository and circe-spray and circe-jackson, but we'll aim to keep it small.
Thanks especially to Jens Raaby and @n4to4 for helping with these transitions.
New cursor operation
ACursor
now has a values
method that's roughly equivalent to fields
, but for JSON arrays instead of JSON objects (#535). This gap has come up a few times in conversations on Gitter and elsewhere—thanks to Eric Torreborre and others for finally convincing me that we should have it.
More concise circe-optics indexing
In circe-optics, JsonPath
(and its Fold
and Traversal
cousins) now have apply
and applyDynamic
methods that support more concise JSON array indexing. For example, instead of root.users.index(1)
you can now write root.users(1)
, and just root(1)
instead of root.index(1)
.
Thanks to Paul Brimicombe for proposing and implementing these changes (#497 and #506).
Traits for generic derivers
Both circe-generic and circe-generic-extras now provide an AutoDerivation
trait that can be mixed into an object that provides other instances. For example, instead of this:
class MyInstances { /* some type class instances here */ }
object MyInstances extends MyInstances
import MyInstances._
import io.circe.generic.auto._
You could write this:
import io.circe.generic.AutoDerivation
class MyInstances { /* some type class instances here */ }
object MyInstances extends MyInstances with AutoDerivation
import MyInstances._
Thanks to Michael Ledin for proposing and implementing this addition (#504).
De-predef-ication
The project now uses scalac's -Yno-predef
option to remove the implicit import scala.Predef._
that Scala source files have by default. This makes the codebase a little more explicit and makes the introduction of operations supported by implicit conversions (which often involve undesirable allocations) easier to notice and avoid.
Thanks to @n4to4 for pushing this effort (started in #320 and #383) over the finish line (#526).
Truncation actually truncates
Previously the truncateToX
methods on JsonNumber
rounded to the nearest whole number:
scala> import io.circe.{ Json, JsonNumber }
import io.circe.{Json, JsonNumber}
scala> JsonNumber.fromString("1.5").map(_.truncateToLong)
res0: Option[Long] = Some(2)
scala> Json.fromDouble(1.5).flatMap(_.asNumber).map(_.truncateToLong)
res1: Option[Long] = Some(2)
scala> Json.fromBigDecimal(BigDecimal(1.5)).asNumber.map(_.truncateToLong)
res2: Option[Long] = Some(2)
This contradicted the API documentation for these methods:
Truncation means that we round toward zero to the closest valid
scala.Long
.
This release fixes the discrepancy by rounding toward zero (as specified in the docs) instead of to the nearest whole value (#533).
Other API changes
- The new
unsafeFilter
method for circe-optics'sJsonPath
that was introduced in 0.7.0-M1 has been renamed tofilterUnsafe
for the sake of consistency (#490). ArrayEncoder
now has a contravariant functor instance (#491).
Other optimizations
- Optimizations for printing (#535).
- Minor optimizations for
ACursor#downN
and tuple decoders (#492). - Minor optimizations for circe-numbers and
JsonNumber
(#494). - Syntactic simplification in
Decoder
(#496). - String formatting optimizations (#534).
Other changes to versions, build configuration, and documentation
- The Scala 2.12 version is now 2.12.1 (#493).
- The Scala.js version is now 0.6.14 (#527).
- The Monocle version for circe-optics is updated to 1.4.0-M2 (#532).
- Build configuration simplifications (#534).
- Adopted sbt-travisci to avoid duplicating Scala version numbers in build configuration (#499).
- The project no longer uses sbt-doge (#519).
- Miscellaneous documentation and metadata improvements (#489, #500, #507, #511, #515, #516, #517, #520).
Thanks to everyone who contributed code or documentation or who offered feedback!