Hi all.
Ā
We're testing the lates Lift-4.0-branch, with Scala-2.13, and some changes in json4s causes us trouble.
Ā
We've persisted serialized values, which we need to load from DB and deserialize. These values can be everything from case class-es to primitives.
Ā
Take this example:
Ā
@Test
def testParseBoolean(): Unit = {
implicit val formats = DefaultFormats.lossless
val jValue = Extraction.decompose(true)
val jsonString = JsonMethods.compact(JsonMethods.render(jValue))
println(jsonString)
val parsedValue = JsonParser.parse(jsonString)
println(parsedValue)
}
Ā
The serialized value is true, but trying to deserialize the value true (parse("true")) results in:
Ā
org.json4s.ParserUtil$ParseException: expected field or array
Near: trueĀ
It's quite inconvenient that it doesn't manage to deserialize the output of the serializer to the same value.
Ā
Anyone knows a way to fix this?
Ā
Seems json4s' has JsonParser.newValue defined as:
def newValue(v: JValue): Unit = {
vals.peekAny match {
case (name: String, _) =>
vals.pop(classOf[JField])
val obj = vals.peek(classOf[JObject])
vals.replace(JObject((name, v) :: obj.obj))
case a: JArray => vals.replace(JArray(v :: a.arr))
case _ => p.fail("expected field or array")
}
}
Ā
While lift-json has:
def newValue(v: JValue) {
if (!vals.isEmpty)
vals.peekAny match {
case JField(name, value) =>
vals.pop(classOf[JField])
val obj = vals.peek(classOf[IntermediateJObject])
obj.fields += (JField(name,v))
case a: IntermediateJArray => a.bits += v
case other => p.fail("expected field or array but got " + other)
} else {
vals.push(v)
root = Some(v)
}
}
Ā
So, for some reason the json4s-team thought it would be fine to just skip āraw fieldsāā¦.
Ā
Anyone familiar with this?
--Ā
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/liftweb/VisenaEmail.0.94bf89a897e1ce64.19b95d670c3%40origo-test01.app.internal.visena.net.
Ā
To view this discussion visit https://groups.google.com/d/msgid/liftweb/VisenaEmail.1.ffba48c23db88945.19b95e70528%40origo-test01.app.internal.visena.net.
Sounds very good, thanks!
Attached patch implements this.
Ā
Any chance of getting it merged upstream?
To view this discussion visit https://groups.google.com/d/msgid/liftweb/VisenaEmail.2.21f7194355caa28c.19b95fc9cb4%40origo-test01.app.internal.visena.net.
Ā
To view this discussion visit https://groups.google.com/d/msgid/liftweb/VisenaEmail.7.7094fcb807e273c7.19ba7e961d5%40origo-test01.app.internal.visena.net.
šøš