How to save form data in an external file

after a FormAction i’ve to save that data collected from the user in a file (json)