Created
May 31, 2014 02:30
-
-
Save manjuraj/3e3926e142a230043f2e to your computer and use it in GitHub Desktop.
jackson notes
This file contains 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
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