我正在尝试解析我保存在一个简单文件中的JSON格式日志,但是收到错误,似乎我的记录不被识别为JSON。
def main(args: Array[String]) {
val out = getContent("file")
val parsedLogs = JSON.parseFull(out) match {
case Some(x) => {
x.asInstanceOf[List[Map[String, Any]]]
}
}
for (log <- parsedLogs) {
//do stuff
}
def getRestContent(url: String): String = {
scala.io.Source.fromFile(url).mkString
}
日志不一致,即每个日志可以是不同的事件,一些样本日志是
{"Event":"SparkListenerLogStart","Spark Version":"2.1.0.43"}
{"Event":"SparkListenerBlockManagerAdded","Block Manager ID":{"Executor
ID":"driver","Host":"127.0.0.0","Port":9090},"Maximum
Memory":956615884,"Timestamp":1499927973730}