Family tree : create JSON file & upload from JSON file

Dear Sir
Developed this family tree from various sources.
Principally code project

http://prajaktasoftware.com/marathetree/familytreecodepen.php

I will like to create whether we can create JSON filr from this structure

This data is JSON by itself, try opening console and running following:

getData();

Sir I am new to JSON

how can i write this in a file or Save data in file

say tree.json

getData() is JQuery command.
and …I am using php