-werners-
Esteemed Contributor III

As Spark can handle nested columns, I would first construct the nested structure in spark (as from spark 3.1.1 there is the excellent column.withField method with which you can create your structure.

Finally write it to json.

That seems to be the easiest way, but your case might be more complex, that is hard to say without some more info.

View solution in original post