Skip to content

Commit

Permalink
TreeSeqMap deserialization (#666)
Browse files Browse the repository at this point in the history
* TreeSeqMap deserialization

* try to fix tests
  • Loading branch information
pjfanning committed Jan 29, 2024
1 parent 2ce4645 commit cc3c95a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ trait UnsortedMapDeserializerModule extends MapTypeModifierModule {
(classOf[mutable.LinkedHashMap[_, _]], mutable.LinkedHashMap),
(classOf[mutable.ListMap[_, _]], mutable.ListMap),
(classOf[mutable.Map[_, _]], mutable.Map),
(classOf[immutable.TreeSeqMap[_, _]], immutable.TreeSeqMap),
(classOf[concurrent.TrieMap[_, _]], concurrent.TrieMap)
))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package tools.jackson.module.scala.deser

import tools.jackson.core.`type`.TypeReference
import tools.jackson.module.scala.{DefaultScalaModule, JacksonModule}

import scala.collection.immutable

class Map2DeserializerTest extends DeserializerTest {

lazy val module: JacksonModule = DefaultScalaModule

"An ObjectMapper with the SortedMapDeserializerModule" should "deserialize an object into an TreeSeqMap" in {
val result = deserialize(mapJson, new TypeReference[immutable.TreeSeqMap[String,String]]{})
result should equal (mapScala)
}

private val mapJson = """{ "one": "1", "two": "2" }"""
private val mapScala = collection.SortedMap("one"->"1","two"->"2")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package tools.jackson.module.scala.deser

import tools.jackson.core.`type`.TypeReference
import tools.jackson.module.scala.{DefaultScalaModule, JacksonModule}

import scala.collection.immutable

class Map2DeserializerTest extends DeserializerTest {

lazy val module: JacksonModule = DefaultScalaModule

"An ObjectMapper with the SortedMapDeserializerModule" should "deserialize an object into an TreeSeqMap" in {
val result = deserialize(mapJson, new TypeReference[immutable.TreeSeqMap[String,String]]{})
result should equal (mapScala)
}

private val mapJson = """{ "one": "1", "two": "2" }"""
private val mapScala = collection.SortedMap("one"->"1","two"->"2")
}

0 comments on commit cc3c95a

Please sign in to comment.