Skip to content

Instantly share code, notes, and snippets.

@akhld
Created February 14, 2015 14:46
Show Gist options
  • Save akhld/3948a5d91d218eaf809d to your computer and use it in GitHub Desktop.
Save akhld/3948a5d91d218eaf809d to your computer and use it in GitHub Desktop.
Jackson Parser
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
/**
* Created by akhld on 14/2/15.
*/
object Parser {
def main(args: Array[String]): Unit ={
val mapper = new ObjectMapper() with ScalaObjectMapper
mapper.registerModule(DefaultScalaModule)
import scala.io.Source
var count = 0
var _map: Map[String, Any] = Map()
for(line <- Source.fromFile("d").getLines()) {
count = count + 1
_map = mapper.readValue[Map[String,Any]](line)
}
println(_map)
println("Count :" + count)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment