Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Converts a DataFrame into a RDD of string or DataFrame.
Syntax
toJSON(use_unicode: bool = True)
Parameters
| Parameter | Type | Description |
|---|---|---|
use_unicode |
bool, optional, default True | Whether to convert to unicode or not. Note that this argument is disallowed in Spark Connect mode. |
Returns
:class:RDD (in Classic mode) or `:class:`DataFrame (in connect mode)
Examples
df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], schema=["age", "name"])
df.toJSON().first()
# '{"age":2,"name":"Alice"}'