Subject: Spark dataset to explode json string


You can try to split the {"foo": "val1", "bar": "val2"} as below.
/*
This is an example of output!
(c1003d93-5157-4092-86cf-0607157291d8,{"rowkey":"c1003d93-5157-4092-86cf-0607157291d8","ticker":"TSCO",
"timeissued":"2019-07-01T09:10:55", "price":395.25})
{"rowkey":"c1003d93-5157-4092-86cf-0607157291d8","ticker":"TSCO",
"timeissued":"2019-07-01T09:10:55", "price":395.25}
*/
// Then I do this to get individual values

           var rowkey =
row._2.split(',').view(0).split(':').view(1).toString.drop(1).dropRight(1).trim
           var ticker = row._2.split(',').view(1).
split(':').view(1).toString.drop(1).dropRight(1).trim
           var timeissued = row._2.split(',').view(2).
toString.substring(14,35).drop(1).dropRight(1).trim
           var price =
row._2.split(',').view(3).split(':').view(1).toString.dropRight(1).toDouble

HTH

Dr Mich Talebzadeh

LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
<https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>*

http://talebzadehmich.wordpress.com
*Disclaimer:* Use it at your own risk. Any and all responsibility for any
loss, damage or destruction of data or any other property which may arise
from relying on this email's technical content is explicitly disclaimed.
The author will in no case be liable for any monetary damages arising from
such loss, damage or destruction.
On Sat, 20 Jul 2019 at 00:00, Richard <[EMAIL PROTECTED]> wrote: