Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Parses a column containing a JSON string into a VariantType. Throws exception if a string represents an invalid JSON value.
Syntax
from pyspark.sql import functions as sf
sf.parse_json(col)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
A column or column name JSON formatted strings. |
Returns
pyspark.sql.Column: a new column of VariantType.
Examples
from pyspark.sql import functions as sf
df = spark.createDataFrame([ {'json': '''{ "a" : 1 }'''} ])
df.select(sf.to_json(sf.parse_json(df.json))).collect()
[Row(to_json(parse_json(json))='{"a":1}')]