Save as json file (similarly as the csv or xml export)

Hi,
I have a server action that in the end I want to save it as a json file (similarly as a csv the csv export). Is it possible to achieve this, or a module is needed? (similar to one of csv, or XML export).

Thank you!

1 Like

Hey Niko,

Haven’t done it and I don’t know if this helps:

(there are 2 links for nodeJS and php…)

Thanks @famousmag for the link. It saves as txt, and need a json format. But thanks anyway!!

Maybe I don’t quite understand what you need - but it seems JSON is essentially plain text with a certain character structure.

Yes, I need to figure out how to add the appropriate formatting in the exported file. Currently, as it is, it only extracts the data, but I need to add the JSON formatting, too.

Thank you!

Have you tried some_object.toJSON() ? Where some_object is your object with the original data.