Json
.obj()
.as[Option[String]](DecodeJson[Option[String]] { hcursor =>
(hcursor --\ "lol").as[Option[String]]
}) shouldBe DecodeResult.ok(None)
Json
.obj()
.as[Option[OrderStatus]](DecodeJson[Option[OrderStatus]] { hcursor =>
(hcursor --\ "lol").as[Option[OrderStatus]]
}) shouldBe DecodeResult.ok(None)
DecodeResult(Left((Attempt to decode value on failed cursor.,CursorHistory(List(El(CursorOpDownField(lol),false)))))) was not equal to DecodeResult(Right(None)) (OrderJsonSpec.scala:30)
"argonaut-jawn" % "6.2.2"
JAR includes only the manifest? Am I missing something? See e.g. http://central.maven.org/maven2/io/argonaut/argonaut-jawn_2.11/6.2.2/argonaut-jawn_2.11-6.2.2.jar
Hi - is argonaut 6.2.2
backwards compatible with 6.2
, i.e. it's truly a "patch" version bump?
Nevermind, I see:
All minor releases (from 6.0 onwards) are binary compatible, i.e. 6.1.x stream are drop in replacements, and the same will be true for 6.2.x, but going from 6.1 to 6.2 may require changes or recompilation.
lift-json
to argonaut
so I can take advantage of Scala Native support and 2.13
support. The is the code I'm trying to convert. https://github.com/ekrich/sconfig/blob/master/sconfig/src/test/scala/org/ekrich/config/impl/JsonTest.scala#L60-L92
toJson
I'm having more luck with. I'm have difficulty with JNumber
pattern matching. I have somelike this.
private[this] def fromJson(json: Json): AbstractConfigValue = {
import scala.collection.JavaConverters._
json match {
case JObject(fields) =>
val m = new HashMap[String, AbstractConfigValue]()
fields.toMap.foreach({ field =>
m.put(field._1, fromJson(field._2))
})
new SimpleConfigObject(fakeOrigin(), m)
case JArray(values) =>
new SimpleConfigList(fakeOrigin(), values.map(fromJson(_)).asJava)
case JNumber(i) =>
i match {
case JsonLong(v) => longValue(v)
case JNumber(v) => i.
}
jNull
and or friends.
Option
of that type.
java.time._
types: implicit val codec: JsonValueCodec[Map[String, List[ZonedDateTime]]] = JsonCodecMaker.make(CodecMakerConfig())
Hi, I have the following string that I pass to a Parse.EncodeEither method like below:
val test ="""{"key":{"serial":0},"checkIn":true,"repositoryID":"rep_id","state":"disabled"} """
val re = Parse.decodeEither[A](test).left.map(MalformedContent(_))
I'am using argonaut 6.2.2, this code result in the below error:
Left(MalformedContent(String: CursorHistory(List(El(CursorOpDownField(serial),true), El(CursorOpDownField(key),true))),None))