diff options
author | Jakob Odersky <jakob@odersky.com> | 2018-03-08 16:13:03 -0800 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2018-03-08 16:21:49 -0800 |
commit | 5ef502abc058358ec3a329c774bb42b9a7bd106f (patch) | |
tree | ee5c20fa79307e1a8397a86f31fbe54cbfe9fe1a /src/main/scala/DerivedFormats.scala | |
parent | eb1ad3c956c828d421b7650dd3b01d5129a41a3d (diff) | |
download | spray-json-derivation-5ef502abc058358ec3a329c774bb42b9a7bd106f.tar.gz spray-json-derivation-5ef502abc058358ec3a329c774bb42b9a7bd106f.tar.bz2 spray-json-derivation-5ef502abc058358ec3a329c774bb42b9a7bd106f.zip |
Don't ake derived formats implicit by defaultv0.3.0
Diffstat (limited to 'src/main/scala/DerivedFormats.scala')
-rw-r--r-- | src/main/scala/DerivedFormats.scala | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/scala/DerivedFormats.scala b/src/main/scala/DerivedFormats.scala index cbfbd61..4339e5c 100644 --- a/src/main/scala/DerivedFormats.scala +++ b/src/main/scala/DerivedFormats.scala @@ -5,7 +5,7 @@ import spray.json._ import scala.language.experimental.macros -/** Mixin that enables automatic derivation of JSON formats for any product +/** Mixin that enables derivation of JSON formats for any product * (case classes) or coproduct (sealed traits) types. */ trait DerivedFormats { self: BasicFormats => type Typeclass[T] = JsonFormat[T] @@ -75,14 +75,17 @@ trait DerivedFormats { self: BasicFormats => } } - implicit def derivedFormat[T]: RootJsonFormat[T] = - macro DerivedFormatHelper.derivedFormat[T] + def jsonFormat[T]: RootJsonFormat[T] = + macro DerivedFormatMacros.derivedFormat[T] } -object DerivedFormats extends DerivedFormats with BasicFormats +trait ImplicitDerivedFormats extends DerivedFormats { self: BasicFormats => + implicit def implicitJsonFormat[T]: RootJsonFormat[T] = + macro DerivedFormatMacros.derivedFormat[T] +} -object DerivedFormatHelper { +object DerivedFormatMacros { import scala.reflect.macros.whitebox._ /** Utility that converts a magnolia-generated JsonFormat to a RootJsonFormat. */ |