【问题标题】:Scala play api json com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input at [Source: ; line: 1, column: 1]Scala play api json com.fasterxml.jackson.databind.JsonMappingException:由于 [Source: ; 的输入结束,没有要映射的内容:行:1,列:1]
【发布时间】:2018-01-30 14:18:48
【问题描述】:
  val nodestring = redisScalaConnector.hget("SPARKDTF", uuid)
  println(nodestring)
  val nodestringparsed: String = nodestring match {
    case None            => ""
    case Some(s: String) => s
  }


  val nodejson = Json.parse(nodestringparsed)
        println(nodejson)
        val delimiter = nodejson.\("delimiter").get.toString().replace("\"", "")
        val tableName = nodejson.\("tablename").get.toString().replace("\"", "").toLowerCase()
        val keySpace = nodejson.\("keyspace").get.toString().replace("\"", "")
        val hostIP = nodejson.\("sourceFileHost").get.toString().replace("\"", "")
        val fileLoc = nodejson.\("sourceFileLoc").get.toString().replace("\"", "")
        val filename = nodejson.\("filename").get.toString().replace("\"", "")
        val connectiontype = nodejson.\("connectiontype").get.toString().replace("\"", "")
        val header = nodejson.\("header").get.toString().replace("\"", "")

    val AutoCreateService = new AutoCreateService(sc)

    var tablequery: Seq[String] = nodejson.\\("tablequery").map(_.as[String])
    println(tablequery)
    AutoCreateService.CqlQueryProcessing(tablequery)

    var metadataquery: Seq[String] = nodejson.\\("metadataquery").map(_.as[String])
    AutoCreateService.CqlQueryProcessing(metadataquery)

我的json如下:

{
  "delimiter": "\t",
  "sourceFileHost": "10.87.88.123",
  "sourceFilePort": "50070",
  "sourceFileLoc": "/nandha/U_Fin_Group.tab",
  "header": false,
  "keyspace": "jofi",
  "connectiontype": "HDFS",
  "filename": "U_Fin_Group.tab",
  "tablename": "fin_group",
  "tablequery": [
    "CREATE KEYSPACE IF NOT EXISTS jofi WITH REPLICATION = { 'class' : 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '1' } AND DURABLE_WRITES = true;",
    "CREATE TABLE IF NOT EXISTS jofi.fin_group(acc_no text,branch text,fin_id text,PRIMARY KEY (fin_id))"
  ],
  "metadataquery": [
    "CREATE TABLE IF NOT EXISTS jofi.metadatatable(colname text,tablename text,checkcondition text,coltype text,filename text,isnull text,maxval text,minval text,sourcecol int,PRIMARY KEY (colname, tablename,filename))",
    "INSERT INTO jofi.metadatatable(colname, tablename, checkcondition, coltype, filename, isnull, maxval, minval, sourcecol)VALUES(?,?,?,?,?,?,?,?,?)",
    [
      "fin_id",
      "fin_group",
      "",
      "text",
      "U_Fin_Group.tab",
      "",
      "",
      "",
      "0"
    ],
    "INSERT INTO jofi.metadatatable(colname, tablename, checkcondition, coltype, filename, isnull, maxval, minval, sourcecol)VALUES(?,?,?,?,?,?,?,?,?)",
    [
      "acc_no",
      "fin_group",
      "",
      "text",
      "U_Fin_Group.tab",
      "",
      "",
      "",
      "2"
    ],
    "INSERT INTO jofi.metadatatable(colname, tablename, checkcondition, coltype, filename, isnull, maxval, minval, sourcecol)VALUES(?,?,?,?,?,?,?,?,?)",
    [
      "branch",
      "fin_group",
      "",
      "text",
      "U_Fin_Group.tab",
      "",
      "",
      "",
      "1"
    ]
  ]
}

【问题讨论】:

  • 我的 json 在这里。

标签: json scala parsing


【解决方案1】:

我得到了这个错误,因为我从 redis 读取的值是我给出的键值是错误的。因此该值重新出现错误,并且没有可读取的值。所以 JSON 解析器正在寻找读取的东西,但它没有正确地得到输入。尝试声明值并正确输入。它对我来说很完美。代码没有问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-23
    • 1970-01-01
    • 2018-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-13
    相关资源
    最近更新 更多