diff options
author | Seth Tisue <seth@tisue.net> | 2017-07-27 19:56:40 -0700 |
---|---|---|
committer | Seth Tisue <seth@tisue.net> | 2017-09-14 13:16:41 -0700 |
commit | 7089839dcfc1c91f195a4b1dcc6d7b60e40b210c (patch) | |
tree | e38509ffd689d673546f17f2a875cee5a583c3a4 /src/main/scala/spray/json/package.scala | |
parent | 8a421f066e99359a3d6fa4cd64cded206376d264 (diff) | |
download | spray-json-7089839dcfc1c91f195a4b1dcc6d7b60e40b210c.tar.gz spray-json-7089839dcfc1c91f195a4b1dcc6d7b60e40b210c.tar.bz2 spray-json-7089839dcfc1c91f195a4b1dcc6d7b60e40b210c.zip |
replace pimp with 'rich', 'enrich', 'extension method'
and:
* add MiMa so we know the change is binary compatible
* use current Scala & sbt versions
Diffstat (limited to 'src/main/scala/spray/json/package.scala')
-rw-r--r-- | src/main/scala/spray/json/package.scala | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main/scala/spray/json/package.scala b/src/main/scala/spray/json/package.scala index f79b99e..37d63c2 100644 --- a/src/main/scala/spray/json/package.scala +++ b/src/main/scala/spray/json/package.scala @@ -25,9 +25,14 @@ package object json { def jsonReader[T](implicit reader: JsonReader[T]) = reader def jsonWriter[T](implicit writer: JsonWriter[T]) = writer - - implicit def pimpAny[T](any: T) = new PimpedAny(any) - implicit def pimpString(string: String) = new PimpedString(string) + + implicit def enrichAny[T](any: T) = new RichAny(any) + implicit def enrichString(string: String) = new RichString(string) + + @deprecated("use enrichAny", "1.3.4") + def pimpAny[T](any: T) = new PimpedAny(any) + @deprecated("use enrichString", "1.3.4") + def pimpString(string: String) = new PimpedString(string) } package json { @@ -35,13 +40,26 @@ package json { case class DeserializationException(msg: String, cause: Throwable = null, fieldNames: List[String] = Nil) extends RuntimeException(msg, cause) class SerializationException(msg: String) extends RuntimeException(msg) + private[json] class RichAny[T](any: T) { + def toJson(implicit writer: JsonWriter[T]): JsValue = writer.write(any) + } + + private[json] class RichString(string: String) { + @deprecated("deprecated in favor of parseJson", "1.2.6") + def asJson: JsValue = parseJson + def parseJson: JsValue = JsonParser(string) + } + + @deprecated("use RichAny", "1.3.4") private[json] class PimpedAny[T](any: T) { def toJson(implicit writer: JsonWriter[T]): JsValue = writer.write(any) } + @deprecated("use RichString", "1.3.4") private[json] class PimpedString(string: String) { @deprecated("deprecated in favor of parseJson", "1.2.6") def asJson: JsValue = parseJson def parseJson: JsValue = JsonParser(string) } + } |