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
Here is a simple method:
$data_json | convertto-json -depth 100 | foreach-object {$_ -replace "(?m) (?<=^(?: )*)", "`t" } | set-content 'output.json'
The foreach-object catches if you pass more than one object to ConvertTo-JSON.
Change the "`t" to what ever you want to do with the indent.
"`t"