@@ -10,12 +10,12 @@ import java.math.BigInteger
1010import java .util .Calendar
1111import java .util .Date
1212import java .util .TimeZone
13-
1413import tools .jackson .databind .JsonNode
1514import tools .jackson .databind .ObjectMapper
1615import play .api .libs .functional .syntax ._
1716import play .api .libs .json .Json ._
1817import play .api .libs .json .jackson .JacksonJson
18+ import tools .jackson .databind .node .{ ArrayNode , BigIntegerNode , DoubleNode , NumericNode , ObjectNode }
1919
2020class JsonSpec extends org.specs2.mutable.Specification {
2121
@@ -469,36 +469,47 @@ class JsonSpec extends org.specs2.mutable.Specification {
469469 }
470470
471471 " Serialize and deserialize Jackson ObjectNodes" in {
472- val on = mapper
472+ val on : ObjectNode = mapper
473473 .createObjectNode()
474474 .put(" foo" , 1 )
475475 .put(" bar" , " two" )
476- val json = Json .obj(" foo" -> 1 , " bar" -> " two" )
477-
476+ val json = Json .obj(" foo" -> 1 , " bar" -> " two" )
477+ val deserialized : JsResult [ JsonNode ] = fromJson[ JsonNode ](json)
478478 toJson(on).must_== (json) and (
479- fromJson[JsonNode ](json).map(_.toString).must_== (JsSuccess (on.toString))
479+ deserialized.map(_.isInstanceOf [ObjectNode ]).must_== (JsSuccess (true ))
480+ ) and (
481+ deserialized.map(_.toString).must_== (JsSuccess (on.toString))
480482 )
481483 }
482484
483485 " Serialize and deserialize Jackson ArrayNodes" in {
484- val an = mapper
486+ val an : ArrayNode = mapper
485487 .createArrayNode()
486488 .add(" one" )
487489 .add(2 )
488- val json = Json .arr(" one" , 2 )
490+ val json = Json .arr(" one" , 2 )
491+ val deserialized : JsResult [JsonNode ] = fromJson[JsonNode ](json)
489492 toJson(an).must(equalTo(json)) and (
490- fromJson[JsonNode ](json).map(_.toString).must_== (JsSuccess (an.toString))
493+ deserialized.map(_.isInstanceOf [ArrayNode ]).must_== (JsSuccess (true ))
494+ ) and (
495+ deserialized.map(_.toString).must_== (JsSuccess (an.toString))
491496 )
492497 }
493498
494499 " Deserialize integer JsNumber as Jackson number node" in {
495- val jsNum = JsNumber (new java.math.BigDecimal (" 50" ))
496- fromJson[JsonNode ](jsNum).map(_.toString).must_== (JsSuccess (" 50" ))
500+ val jsNum = JsNumber (new java.math.BigDecimal (" 50" ))
501+ val deserialized : JsResult [JsonNode ] = fromJson[JsonNode ](jsNum)
502+ deserialized.map(_.isInstanceOf [NumericNode ]).must_== (JsSuccess (true )) and (
503+ deserialized.map(_.toString).must_== (JsSuccess (" 50" ))
504+ )
497505 }
498506
499507 " Deserialize float JsNumber as Jackson number node" in {
500- val jsNum = JsNumber (new java.math.BigDecimal (" 12.345" ))
501- fromJson[JsonNode ](jsNum).map(_.toString).must_== (JsSuccess (" 12.345" ))
508+ val jsNum = JsNumber (new java.math.BigDecimal (" 12.345" ))
509+ val deserialized : JsResult [JsonNode ] = fromJson[JsonNode ](jsNum)
510+ deserialized.map(_.isInstanceOf [NumericNode ]).must_== (JsSuccess (true )) and (
511+ deserialized.map(_.toString).must_== (JsSuccess (" 12.345" ))
512+ )
502513 }
503514
504515 " Serialize JsNumbers with integers correctly" in {
0 commit comments