Files
2018-11-19 22:41:26 +08:00

17 lines
533 B
PowerShell

Function Save-VCGJsonFile{
Param(
[Parameter(Mandatory=$true)] $FileName,
[Parameter(Mandatory=$true)] $Data,
[Parameter(Mandatory=$true)] $Dir
)
$json = @()
$Data | ForEach-Object { $json += $_.to_jsonobj()}
if (!(Test-Path $Dir)) {
New-Item -Type directory -Confirm:$false -Path $Dir -Force |Out-Null
}
$Path= $Dir + '\' + $FileName + '.json'
info ("Saving data to " + $Path)
ConvertTo-Json -Depth 10 -Compress $json | Out-File -encoding 'UTF8' -FilePath $Path
}