Skip to content

Instantly share code, notes, and snippets.

@OndrejSpanel
Forked from crimsoncor/JacksonMapTest.scala
Last active August 29, 2015 14:24
Show Gist options
  • Save OndrejSpanel/53e8bf9a975c5cbdb534 to your computer and use it in GitHub Desktop.
Save OndrejSpanel/53e8bf9a975c5cbdb534 to your computer and use it in GitHub Desktop.
Updated Broken Scala Map to JSON to match recent package naming and language style
package test
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
object Main extends App {
val mapper = new ObjectMapper()
mapper.registerModule(DefaultScalaModule)
val map = Map((2, 3) -> "Horsey")
println(map)
val out = mapper.writeValueAsString(map)
println(out)
val result = mapper.readValue(out, classOf[Map[Tuple2[Int, Int], String]])
result.foreach(e => println(e._1.getClass))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment