private function save_json( $json, $filename)
	{
		$extension = pathinfo( $filename, PATHINFO_EXTENSION );
		$output_basename = pathinfo( $filename, PATHINFO_FILENAME );

		if ( $extension == 'zip' )
		{
			/**
			 * @var ZipArchive $zip
			 */
			$zip = new ZipArchive();
			$zip->open( $filename, ZipArchive::CREATE );
			$zip->addFromString( "$output_basename.json", $json );

			if ( $zip->close() === false )
			{
				$message = "Error closing zip file: " . $zip->getStatusString();
				throw new \Exception( $message );
			}
		}
		else if ( $extension != 'json' )
		{
			$message = "Only files with .zip or .json extension are supported";
			throw new \Exception( $message );
		}
		else
		{
			if ( file_put_contents( $filename, $json ) === false )
			{
				$message = "Failed to write ";
				throw new \Exception( $message );
			}
		}
	}