This is my input data frame structure

```
root
|--Name (String)
|--Version (int)
|--Details (array)

```

Something like this : 

```
"Name":"json",
"Version":1,
"Details":[
"{
    \"Id\":\"123\",
    \"TaxDetails\":[\"TaxDetail1\":\"val1\", \"TaxDetail2\":\"val2\"]
}",
"{
    \"Id\":\"234\",
    \"TaxDetails\":[\"TaxDetail3\":\"val3\", \"TaxDetail4\":\"val4\"]
}"
]

```

I want to explode this at level of TaxDetails something like this :

```
"Name":"json",
"Version":1,
"TaxDetail":{\"TaxDetail1\":\"val1\"}   

"Name":"json",
"Version":1,
"TaxDetail":{\"TaxDetail2\":\"val2\"}   

"Name":"json",
"Version":1,
"TaxDetail":{\"TaxDetail3\":\"val3\"}   

"Name":"json",
"Version":1,
"TaxDetail":{\"TaxDetail4\":\"va4\"}

```

I have exploded the Details with explode function like this 

```
val explodedDetailDf = inputDf.withColumn("Detail", explode($"Details"))

```

Now the data type of column 'Detail' is string and when I am trying to do this:

```
val explodedTaxDetail = explodedDetailDf.withColumn("TaxDetail", explode($"Detail.TaxDetails"))

```

Above operation is failing with error "AnalysisException due to data type mismatch: input to function explode should be array or map type, not String"

How can I explode a nested json array based on it's name?