0
我在一個視圖中的措辭運行我的地方(http://127.0.0.1:5984/sample/_design/view/_view/data)
輸入:
的結果查看如下:
{"total_rows":3,"offset":0,"rows":[
{"id":"1","key":["2032","0"],"value":{"context":"2032","application_id":"2412"}},
{"id":"21","key":["214","0"],"value":{"context":"1312","application_id":"4242"}}
]}
目標:
我想在火花來解析這一點,因此我寫了下面的代碼
代碼:
// For implicit conversions like converting RDDs to DataFrames
import spark.implicits._
// SQL context
import org.apache.spark.sql.SparkSession
// Importing CouchDB Connector (made by my someone in our office)
import com.artoo.spark.connector.couch.CouchConnectorCore
// JSON parser
import org.json4s.native.JsonMethods._
val connector = new CouchConnectorCore("http://127.0.0.1:5984/sample/_design/view/_view/data?since=0&limit=10", "0", 10)
connector.start()
// getting data
val json = connector.getData
// printing results
println(json)
// parse son
val parsed_json = parse(json)
問題:
val parsed_json = parse(json)
error: overloaded method value parse with alternatives:
(in: org.json4s.JsonInput,useBigDecimalForDouble: Boolean,useBigIntForLong: Boolean)org.json4s.JValue <and>
(in: org.json4s.JsonInput,useBigDecimalForDouble: Boolean)org.json4s.JValue
cannot be applied to (String)
val parsed_json = parse(json)
PS:
事情運行正常,直到 「的println(JSON)」,它的輸出是與上述相同的
運行在火花2.1.0用Hadoop 2.7所示的 「輸入」,在OSX
Scala的版本2.11.8