pyspark dataframe json string 1

pyspark dataframe json string

newJson = '{"Name":"something","Url":"https://stackoverflow.com","Author":"jangcy","BlogEntries":100,"Caller":"jangcy"}'
df = spark.read.json(sc.parallelize([newJson]))
df.show(truncate=False)

Here is what the above code is Doing:
1. Create a new JSON string
2. Create a new DataFrame from the JSON string
3. Show the DataFrame

Similar Posts