Skip to content

Upgrade circe to 0.9.1 #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import io.circe.{ ACursor, Decoder, HCursor, Json }
abstract class JsonProductCodec {
def encodeEmpty: Json
def encodeField(field: (String, Json), obj: Json, default: => Option[Json]): Json

def decodeEmpty(cursor: HCursor): Decoder.Result[Unit]
def decodeField[A](name: String, cursor: HCursor, decode: Decoder[A], default: Option[A]): Decoder.Result[(A, ACursor)]
}
Expand Down Expand Up @@ -48,15 +48,15 @@ class JsonProductObjCodec extends JsonProductCodec {
def decodeEmpty(cursor: HCursor): Decoder.Result[Unit] = Right(())
def decodeField[A](name: String, cursor: HCursor, decode: Decoder[A], default: Option[A]): Decoder.Result[(A, ACursor)] = {
val c = cursor.downField(toJsonName(name))
def result = c.as(decode).right.map((_, ACursor.ok(cursor)))
def result = c.as(decode).right.map((_, cursor))

default match {
case None => result
case Some(d) =>
if (c.succeeded)
result
else
Right((d, ACursor.ok(cursor)))
Right((d, cursor))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class JsonSumObjCodec extends JsonSumCodec {
cursor.history
))
def decodeField[A](name: String, cursor: HCursor, decode: Decoder[A]): Decoder.Result[Either[ACursor, A]] =
cursor.downField(toJsonName(name)).either match {
case Left(_) =>
Right(Left(ACursor.ok(cursor)))
case Right(content) =>
cursor.downField(toJsonName(name)).success match {
case None =>
Right(Left(cursor))
case Some(content) =>
decode(content).right.map(Right(_))
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ class JsonSumTypeFieldCodec extends JsonSumCodec {
case Right(name0) if toTypeValue(name) == name0 =>
c.delete.as(decode).right.map(Right(_))
case _ =>
Right(Left(ACursor.ok(cursor)))
Right(Left(cursor))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ object ProductEncodeTests extends TestSuite {
Default.AsOptions[WrappedMap],
HListProductEncoder.hcons(
Witness('m),
Encoder.encodeMapLike[Map, String, Json](KeyEncoder.encodeKeyString, Encoder.encodeJson),
Encoder.encodeMapLike[String, Json, Map](KeyEncoder.encodeKeyString, Encoder.encodeJson, identity),
HListProductEncoder.hnil
)
),
Expand Down
2 changes: 1 addition & 1 deletion project/Deps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Deps {
import Def.setting

private val jupyterScalaVersion = "0.4.0"
private val circeVersion = "0.6.1"
private val circeVersion = "0.9.1"


def circeCore = setting("io.circe" %%% "circe-core" % circeVersion)
Expand Down
2 changes: 1 addition & 1 deletion render/js/src/main/scala/plotly/Plotly.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import java.lang.{Boolean => JBoolean, Double => JDouble, Integer => JInt}

object Plotly {

private val printer = Printer.noSpaces.copy(dropNullKeys = true)
private val printer = Printer.noSpaces.copy(dropNullValues = true)
private def stripNulls(json: Json): js.Any = {
// Remove empty objects
JSON.parse(printer.pretty(json))
Expand Down
6 changes: 3 additions & 3 deletions render/jvm/src/main/scala/plotly/Plotly.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import scala.annotation.tailrec

object Plotly {

private val printer = Printer.noSpaces.copy(dropNullKeys = true)
private val printer = Printer.noSpaces.copy(dropNullValues = true)

def jsSnippet(div: String, data: Seq[Trace], layout: Layout): String = {

Expand Down Expand Up @@ -182,7 +182,7 @@ object Plotly {
openInBrowser = openInBrowser,
addSuffixIfExists = addSuffixIfExists
)

def plot(
path: String = "./plot.html",
title: String = null,
Expand Down Expand Up @@ -267,7 +267,7 @@ object Plotly {
openInBrowser = openInBrowser,
addSuffixIfExists = addSuffixIfExists
)

def plot(
path: String = "./plot.html",
title: String = null,
Expand Down
20 changes: 10 additions & 10 deletions render/shared/src/main/scala/plotly/Codecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ object Codecs {
Right {
val o = decode(cursor)
o.right.toOption
.toRight(ACursor.ok(cursor))
.toRight(cursor)
}
}

Expand All @@ -176,7 +176,7 @@ object Codecs {
underlying.encodeField(field, obj, default)

def decodeEmpty(cursor: HCursor): Decoder.Result[Unit] =
if (cursor.focus == Json.obj())
if (cursor.focus.contains(Json.obj()))
Right(())
else
Left(DecodingFailure(
Expand All @@ -187,15 +187,15 @@ object Codecs {
def decodeField[A](name: String, cursor: HCursor, decode: Decoder[A], default: Option[A]): Decoder.Result[(A, ACursor)] = {
val c = cursor.downField(toJsonName(name))

def result = c.as(decode).right.map((_, if (c.succeeded) c.delete else cursor.acursor))
def result = c.as(decode).right.map((_, if (c.succeeded) c.delete else cursor))

default match {
case None => result
case Some(d) =>
if (c.succeeded)
result
else
Right((d, ACursor.ok(cursor)))
Right((d, cursor))
}
}
}
Expand Down Expand Up @@ -404,12 +404,12 @@ object Codecs {

implicit val decodeError: Decoder[Error] =
Decoder.instance { c =>
c.downField("type").either match {
case Left(c0) =>
Left(DecodingFailure("No type found", c0.history))
case Right(c1) =>
c.downField("type").success match {
case None =>
Left(DecodingFailure("No type found", c.history))
case Some(c1) =>
val c0 = c1.delete
c1.focus.as[String].right.flatMap {
c1.focus.get.as[String].right.flatMap {
case "data" =>
c0.as[Error.Data].right.map(e => e: Error)
case "percent" =>
Expand Down Expand Up @@ -449,7 +449,7 @@ object Codecs {
case Left(_) if name == "Scatter" => // assume scatter if no type found
cursor.as(decode).right.map(Right(_))
case _ =>
Right(Left(ACursor.ok(cursor)))
Right(Left(cursor))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/plotly/doc/SchemaTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object SchemaTests {
val constantString = c.as[String].right.map[Attribute](ConstantString(_))
def flag = c.as[Flag].right.map[Attribute](x => x)
def enumerated = c.as[Enumerated].right.map[Attribute](x => x)
def other = Right(Other(c.focus))
def other = Right(Other(c.focus.get))

constantString.right.toOption.map(Right(_))
.orElse(flag.right.toOption.map(Right(_)))
Expand Down