调用spark 的隐式转换
scala> import spark.implicits._
import spark.implicits._
scala> val df=sc.parallelize(Array(("a",1),("b",2),("c",3)))
scala> df.show()
+---+---+
| _1| _2|
+---+---+
| a| 1|
| b| 2|
| c| 3|
+---+---+
scala> val jsonStr=df.toJSON.collect()
jsonStr: Array[String] = Array({"_1":"a","_2":1}, {"_1":"b","_2":2}, {"_1":"c","_2":3})