For example, I have this Map value in Scala:
val m = Map(
\"name\" -> \"john doe\",
\"age\" -> 18,
\"hasChild\" -> true,
\"childs\" -
One thing you can do using the Jackson library is to use a java HashMap object, instead of a Scala one. Then you can basically use the same "without success" code you already wrote.
import org.codehaus.jackson.map.ObjectMapper
val mapper = new ObjectMapper()
val jmap = new java.util.HashMap[String, Int]()
jmap.put("dog", 4)
jmap.put("cat", 1)
// convert to json formatted string
val jstring = mapper.writeValueAsString(jmap)
println(jstring)
returns
jstring: String = {"dog":4,"cat":1}