Skip to content

Commit cc3c95a

Browse files
committed
TreeSeqMap deserialization (#666)
* TreeSeqMap deserialization * try to fix tests
1 parent 2ce4645 commit cc3c95a

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/main/scala-2.13/tools/jackson/module/scala/deser/UnsortedMapDeserializerModule.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ trait UnsortedMapDeserializerModule extends MapTypeModifierModule {
3030
(classOf[mutable.LinkedHashMap[_, _]], mutable.LinkedHashMap),
3131
(classOf[mutable.ListMap[_, _]], mutable.ListMap),
3232
(classOf[mutable.Map[_, _]], mutable.Map),
33+
(classOf[immutable.TreeSeqMap[_, _]], immutable.TreeSeqMap),
3334
(classOf[concurrent.TrieMap[_, _]], concurrent.TrieMap)
3435
))
3536

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package tools.jackson.module.scala.deser
2+
3+
import tools.jackson.core.`type`.TypeReference
4+
import tools.jackson.module.scala.{DefaultScalaModule, JacksonModule}
5+
6+
import scala.collection.immutable
7+
8+
class Map2DeserializerTest extends DeserializerTest {
9+
10+
lazy val module: JacksonModule = DefaultScalaModule
11+
12+
"An ObjectMapper with the SortedMapDeserializerModule" should "deserialize an object into an TreeSeqMap" in {
13+
val result = deserialize(mapJson, new TypeReference[immutable.TreeSeqMap[String,String]]{})
14+
result should equal (mapScala)
15+
}
16+
17+
private val mapJson = """{ "one": "1", "two": "2" }"""
18+
private val mapScala = collection.SortedMap("one"->"1","two"->"2")
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package tools.jackson.module.scala.deser
2+
3+
import tools.jackson.core.`type`.TypeReference
4+
import tools.jackson.module.scala.{DefaultScalaModule, JacksonModule}
5+
6+
import scala.collection.immutable
7+
8+
class Map2DeserializerTest extends DeserializerTest {
9+
10+
lazy val module: JacksonModule = DefaultScalaModule
11+
12+
"An ObjectMapper with the SortedMapDeserializerModule" should "deserialize an object into an TreeSeqMap" in {
13+
val result = deserialize(mapJson, new TypeReference[immutable.TreeSeqMap[String,String]]{})
14+
result should equal (mapScala)
15+
}
16+
17+
private val mapJson = """{ "one": "1", "two": "2" }"""
18+
private val mapScala = collection.SortedMap("one"->"1","two"->"2")
19+
}

0 commit comments

Comments
 (0)