I am creating a JSON in Powershell and I want to set a custom tab width when building it (instead of the default 4 white spaces I want to set only 2 white spaces).
I am
The following code will halve the size of indent:
$json = @" { "Phone": "SomePhone", "Description": "Lorem ipsum dolor..", "Price": 99.99 } "@ ($json -split '\r\n' | % { $line = $_ if ($_ -match '^ +') { $len = $Matches[0].Length / 2 $line = ' ' * $len + $line.TrimStart() } $line }) -join "`r`n"