26 lines
628 B
PowerShell
26 lines
628 B
PowerShell
param (
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$jsonfile,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$output
|
|
|
|
)
|
|
|
|
# Read the original JSON data from the file
|
|
$JsonData = Get-Content -Path $jsonfile -Raw
|
|
|
|
# Convert JSON string to a PowerShell object
|
|
$JsonObject = $JsonData | ConvertFrom-Json
|
|
|
|
# Convert back to JSON with indentation and formatting
|
|
$FormattedJson = $JsonObject | ConvertTo-Json -Depth 10
|
|
|
|
# Write the formatted JSON string to the output file
|
|
Set-Content -Path $output -Value $FormattedJson
|
|
|
|
remove-item $jsonfile -Force -Verbose
|
|
|
|
Write-Host "✅ JSON reformatted with line breaks and saved to: $output"
|
|
|