Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix serialization of an opaque value

  • Loading branch information...
commit 04b4aeac7ec71d2ef246bf08ae202aeccbfcf338 1 parent f11fa2f
Joni Freeman authored
View
1  core/json/src/main/scala/net/liftweb/json/Extraction.scala
@@ -76,6 +76,7 @@ object Extraction {
} else if (!serializer.isDefinedAt(a)) {
any match {
case null => JNull
+ case x: JValue => x
case x if primitive_?(x.getClass) => primitive2jvalue(x)(formats)
case x: Map[_, _] => JObject((x map { case (k: String, v) => JField(k, decompose(v)) }).toList)
case x: Collection[_] => JArray(x.toList map decompose)
View
7 core/json/src/test/scala/net/liftweb/json/SerializationBugs.scala
@@ -111,6 +111,12 @@ object SerializationBugs extends Specification {
val ser = Extraction.decompose(seq)
Extraction.extract[Seq[Int]](ser) mustEqual seq
}
+
+ "Serialization of an opaque value should not fail" in {
+ val o = Opaque(JObject(JField("some", JString("data")) :: Nil))
+ val ser = Serialization.write(o)
+ ser mustEqual """{"x":{"some":"data"}}"""
+ }
}
case class LongList(xs: List[Num])
@@ -135,3 +141,4 @@ package plan2 {
inParams: Array[Number], subOperand: Option[Action])
}
+case class Opaque(x: JValue)
Please sign in to comment.
Something went wrong with that request. Please try again.