Skip to content

Instantly share code, notes, and snippets.

@manjuraj
Created May 31, 2014 02:30
Show Gist options
  • Save manjuraj/3e3926e142a230043f2e to your computer and use it in GitHub Desktop.
Save manjuraj/3e3926e142a230043f2e to your computer and use it in GitHub Desktop.
jackson notes
import com.fasterxml.jackson.core.{JsonGenerator, JsonToken, JsonParser, JsonFactory}
import com.fasterxml.jackson.databind._
val mapper = new ObjectMapper
val jsonFactory = new JsonFactory(mapper)
val content =
"""
{
"name" : "Watership Down",
"location" : {
"lat" : 51.235685,
"long" : -1.309197
},
"residents" : [ {
"name" : "Fiver",
"age" : 4,
"role" : null
}, {
"name" : "Bigwig",
"age" : 6,
"role" : "Owsla"
} ]
}
"""
val jsonParser = jsonFactory.createParser(content)
val json = mapper.readValue(jsonParser, classOf[java.util.Map[String, Any]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment