json array file explode like below output in pyspark

json array file explode like below output in pyspark


Solution:

df = spark.read.format("json").load("file:////home/cloudera/testxxx/listOfFruit.json")

df.show(truncate=False)


dfp= df.withColumn("list_of_fruit",explode("list_of_fruit"))

dfp.show()


Comments