DataFrameWriter.
json
Saves the content of the DataFrame in JSON format (JSON Lines text format or newline-delimited JSON) at the specified path.
DataFrame
New in version 1.4.0.
the path in any Hadoop supported file system
specifies the behavior of the save operation when data already exists.
append: Append contents of this DataFrame to existing data.
append
overwrite: Overwrite existing data.
overwrite
ignore: Silently ignore this operation if data already exists.
ignore
error or errorifexists (default case): Throw an exception if data already exists.
error
errorifexists
For the extra options, refer to Data Source Option in the version you use.
Examples
>>> df.write.json(os.path.join(tempfile.mkdtemp(), 'data'))