How to save files in different file formats other than textfile along with compression

Hi

Can you help me with the command to save file in different file formats json avro and parquet file format.

I tired saving the data frames using below commands with compression and the commands are failing.

Data.save("/filepath ",“parquet”,“snappy”)

Data.save("/filepath ",“json”,“snappy”)

Data.toJSON().saveAsTextFile(“path”,“compressionCodecClass=”"") – this commands seems to work fine but the file save doenst have .json extension

Thanks,
Sakshi