Dataframe to JSON (Spark / Scala ) -Error extra forward slash in output

Need one help in below error

I am trying to convert below Data frame to Json

DataFrame Attached

Expected Output :

{"source:“abc”,“id”:“123”,“more_detail” :


What Output I am getting :

{"source:“abc”,“id”:“123”,“more_detail” :

["{ \ “mid \ “:\“10\”,\“date\”:\“11090900000\”,\“type\”:\“abc\”}”,”{ \ “mid \ “:\“11\”,\“date\”:\“11230900000\”,\“type\”:\“jkl\”}”,”{ \ "mid \“:\“13\”,\“date\”:\“1107878000\”,\“type\”:\“kiu\”}”]}

What I tried :

def func1( records :Dataframe) :Unit =

{ (to_json(struct(col(“mid”),col(date),col(type))).show(truncate(false)

val df =“source”),



val m = JSON

println(m.collect().mkstring(" , "))

Please advise so that I can get expected output