2017-08-22 2 views
0
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:Scala play api json com.fasterxml.jackson.databind.JsonMappingException:[Source:;]の入力終了のためにマップするコンテンツがありません。行:1、列:以下1]

{ 
    "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" 
    ] 
    ] 
} 

enter image description here

+0

私のjsonはここにあります。 –

答えて

0

私はこのエラーがRedisのからの読み取り値イムを起こしましたが、私が与えたキー値では間違っています。値はエラーを返し、読み取る値はありません。 JSONパーサは何かを読みたいと思っていますが、入力が正しくないのです。値を宣言して正しく入力しようとしました。それは私のために完璧に働いた。コードに何も問題はありません。

関連する問題