In Scala, how can I convert a comma separated string to an array with double quoted elements?
I have tried as below:
var string = "welcome,to,my,world"
var array = string.split(',').mkString("\"", "\",\"", "\"")
Output:
[ "\"welcome\",\"to\",\"my\",\"world\""]
My requirement is for the array to appear as:
["welcome","to","my","world"]
I also tried using the below method:
var array = string.split(",").mkString(""""""", """","""", """"""")
Output:["\"ENV1\",\"ENV2\",\"ENV3\",\"ENV5\",\"Prod\""]