Reputation: 129
val conf = new SparkConf().setAppName("test").setMaster("local")
val sc = new SparkContext(conf)
val sqlContext = new SQLContext(sc)
val input = sqlContext.read.json("input.json")
input.select("email", "first_name").where("email=='[email protected]'").show()
I am getting following response
How can I get response as a JSON Object?
Upvotes: 0
Views: 688
Reputation: 1027
You can write it to Json File : https://www.tutorialkart.com/apache-spark/spark-write-dataset-to-json-file-example/
Or if you prefer to show it as a Dataset of Json Strings, use the toJSON
function :
input
.select("email", "first_name")
.where("email=='[email protected]'")
.toJSON()
.show()
Upvotes: 2