to get the PHP back into JSON, you can do
$group = array(
// the PHP field group
);
$json = json_encode($group);
and then you can write the json to a file using PHP http://php.net/manual/en/function.file-put-contents.php. Once that’s done you can download the file and then import it.