Created
August 3, 2012 01:40
-
-
Save crimsoncor/3243273 to your computer and use it in GitHub Desktop.
Broken Scala Map to JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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