I had tried this, but it creates in the delta format, viz., the json output file contains one row for each record in the table.

2023-02-24 22_08_34-MyTest - Databricks 2 

And the same thing happens if I use to_json as shown below. Since the examples in the databricks docs, I'm unable to construct a proper query:

2023-02-24 22_08_34-MyTest - Databricks 3 

Lastly, the intension of required json output as a file, is for the file based integration with other systems.

Hope that clarifies!