Adapt to recent changes to sjson-new

This commit is contained in:
Martin Duhem 2016-07-24 21:42:03 +01:00
parent 465774b13c
commit feda07b896
3 changed files with 12 additions and 14 deletions

View File

@ -10,19 +10,19 @@ import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, File, InputStream,
import java.net.{ URI, URL }
trait URIFormat { self: BasicJsonProtocol =>
implicit def URIFormat: JsonFormat[URI] = wrap(_.toString, new URI(_: String))
implicit def URIFormat: JsonFormat[URI] = project(_.toString, new URI(_: String))
}
trait URLFormat { self: BasicJsonProtocol =>
implicit def URLFormat: JsonFormat[URL] = wrap(_.toString, new URL(_: String))
implicit def URLFormat: JsonFormat[URL] = project(_.toString, new URL(_: String))
}
trait FileFormat { self: BasicJsonProtocol =>
implicit def FileFormat: JsonFormat[File] = wrap(_.toString, new File(_: String))
implicit def FileFormat: JsonFormat[File] = project(_.toString, new File(_: String))
}
trait SetFormat { self: BasicJsonProtocol =>
implicit def SetFormat[T: JsonFormat]: JsonFormat[Set[T]] = wrap(_.toSeq, (_: Seq[T]).toSet)
implicit def SetFormat[T: JsonFormat]: JsonFormat[Set[T]] = project(_.toSeq, (_: Seq[T]).toSet)
}
trait HListFormat {

View File

@ -15,15 +15,13 @@ object StampedFormat extends BasicJsonProtocol {
override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): T =
jsOpt match {
case Some(js) =>
unbuilder.extractArray(js) match {
case Vector(readStamp, readValue) =>
val actualStamp = formatStamp.read(Some(readStamp), unbuilder)
if (equivStamp.equiv(actualStamp, stamp)) format.read(Some(readValue), unbuilder)
else sys.error(s"Incorrect stamp. Expected: $stamp, Found: $readStamp")
case other =>
deserializationError(s"Expected JsArray of size 2, but found JsArray of size ${other.size}")
}
val stampedLength = unbuilder.beginArray(js)
if (stampedLength != 2) sys.error(s"Expected JsArray of size 2, found JsArray of size $stampedLength.")
val readStamp = unbuilder.nextElement
val readValue = unbuilder.nextElement
val actualStamp = formatStamp.read(Some(readStamp), unbuilder)
if (equivStamp.equiv(actualStamp, stamp)) format.read(Some(readValue), unbuilder)
else sys.error(s"Incorrect stamp. Expected: $stamp, Found: $readStamp")
case None =>
deserializationError("Expected JsArray but found None.")

View File

@ -26,7 +26,7 @@ object Dependencies {
lazy val parserCombinator211 = "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"
lazy val sjsonnewVersion = "0.4.0"
lazy val sjsonnewVersion = "0.4.1"
lazy val sjsonnew = "com.eed3si9n" %% "sjson-new-core" % sjsonnewVersion
lazy val sjsonnewScalaJson = "com.eed3si9n" %% "sjson-new-scalajson" % sjsonnewVersion
}