且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

怎么把DataFrame转换成Json?

更新时间:2023-02-19 14:16:46

val result: DataFrame = sqlContext.read.json(path)
result.write.json("/yourPath")

方法write在类

The method write is in the class DataFrameWriter and should be accessible to you on DataFrame objects. Just make sure that your rdd is of type DataFrame and not of deprecated type SchemaRdd. You can explicitly provide type definition val data: DataFrame or cast to dataFrame with toDF().