I have an Array of JSON String, which I need to parse and convert into a struct.
transDf schema:
root
|-- logs: array (nullable = true)
| |-- element: string (containsNull = true)
This is the code I tried
val logsSchema = new ArrayType(spark.read.json(transDf.select("logs").as[String]).schema, true)
transDf = transDf.withColumn("logs", from_json(col("logs"), logsSchema))
but the above thing only works for string -> struct but not for Array struct.
How can I convert the array for JSON string into Array<Struct> without knowing the schema of the JSON.
transDfdataframe? This will help in helping you :)