Skip to content

Instantly share code, notes, and snippets.

@crimsoncor
Created August 3, 2012 01:40
Show Gist options
  • Save crimsoncor/3243273 to your computer and use it in GitHub Desktop.
Save crimsoncor/3243273 to your computer and use it in GitHub Desktop.
Broken Scala Map to JSON
package test
import org.codehaus.jackson.map.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
object JacksonMapTest {
def main(args: Array[String]): Unit = {
val map = Map((2, 3) -> "Horsey")
val mapper = new ObjectMapper()
mapper.registerModule(DefaultScalaModule)
val writer = new java.io.StringWriter()
mapper.writeValue(writer, map)
println(map)
println(writer)
val result = mapper.readValue(writer.toString, 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