Spark Row to JSON

后端 未结 4 2055
灰色年华
灰色年华 2020-11-30 03:19

I would like to create a JSON from a Spark v.1.6 (using scala) dataframe. I know that there is the simple solution of doing df.toJSON.

However, my probl

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 04:02

    I use this command to solve the to_json problem:

    output_df = (df.select(to_json(struct(col("*"))).alias("content")))
    

提交回复
热议问题