How to read single line JSON in spark

How to read single line JSON in spark



Let the data be as below

example.json

{"name": "shiva","gender": "male","id": "1"}
{"name": "ram","gender": "male","id": "2"}
{"name": "raju","gender": "male","id": "3"}



Source code:

df = spark.read.json("s3://mybucket/example.json")

df.show()


Output







Comments