param( [Parameter(Mandatory)] [string]$Path ) $json = Get-Content $Path -Raw | ConvertFrom-Json $directory = Split-Path $Path -Parent $fileName = [System.IO.Path]::GetFileNameWithoutExtension($Path) $newPath = Join-Path $directory "${fileName}_new.json" $jsonText = $json | ConvertTo-Json -Depth 100 # UTF-8(BOMなし)を明示して保存するため WriteAllText() を使用。 # Set-Content / Out-File は PowerShell バージョンによって既定エンコーディングの差異があるため、 # スニペットとしては .NET API を直接利用する。 [System.IO.File]::WriteAllText( $newPath, $jsonText, [System.Text.UTF8Encoding]::new($false) )