Permalink
Browse files

Array was incorrectly checked

  • Loading branch information...
1 parent 655789c commit ea5f68c2208ea3d7907e7a089b0883d89e54a876 Joni Freeman committed Mar 20, 2011
@@ -167,7 +167,7 @@ object Extraction {
private def extract0[A](json: JValue, mf: Manifest[A])(implicit formats: Formats): A = {
val mapping =
- if (mf.erasure == classOf[List[_]] || mf.erasure == classOf[Set[_]] || mf.erasure == classOf[Array[_]])
+ if (mf.erasure == classOf[List[_]] || mf.erasure == classOf[Set[_]] || mf.erasure.isArray)
Col(mf.erasure, mappingOf(mf.typeArguments(0).erasure))
else if (mf.erasure == classOf[Map[_, _]])
Dict(mappingOf(mf.typeArguments(1).erasure))
@@ -41,6 +41,13 @@ object ExtractionBugs extends Specification("Extraction bugs Specification") {
args.size mustEqual 4
}
+ "Extraction should handle AnyRef" in {
+ implicit val formats = DefaultFormats.withHints(FullTypeHints(classOf[ExtractWithAnyRef] :: Nil))
+ val json = JObject(JField("jsonClass", JString(classOf[ExtractWithAnyRef].getName)) :: Nil)
+ val extracted = Extraction.extract[AnyRef](json)
+ extracted mustEqual ExtractWithAnyRef()
+ }
+
case class OptionOfInt(opt: Option[Int])
case class PMap(m: Map[String, List[String]])
@@ -50,4 +57,6 @@ object ExtractionBugs extends Specification("Extraction bugs Specification") {
def this(name: String) = this(0, name, "Doe", "")
def this(name: String, email: String) = this(0, name, "Doe", email)
}
+
+ case class ExtractWithAnyRef()
}

0 comments on commit ea5f68c

Please sign in to comment.