pyspark.sql.DataFrame.toJSON

DataFrame.toJSON(use_unicode: bool = True) → pyspark.rdd.RDD[str][source]

Converts a DataFrame into a RDD of string.

Each row is turned into a JSON document as one element in the returned RDD.

New in version 1.3.0.

Examples

>>> df.toJSON().first()
'{"age":2,"name":"Alice"}'