I have a text file which has JSON data something like this:
{
"element" : value,
"id" : value,
"total" : []
}
{
"element" : value,
"id" : value,
"total: []
}
All the JSON are new line separated.
I am trying to load all the text files data into a temp view :
sqlContext.read.textFiles("/path").createOrReplaceTempView("result")
val data = sqlContext.sql("select * from result").collect()
Result:
[{"element" : value,"id" : value,"total" : [] }]
[{"element" : value,"id" : value, "total" : []}]
I need to extract the id and the total related to it.
Is there a way in spark to handle this?