Prettify json in powershell 3

Works for me. Parentheses make sure get-content is done before piping. Default depth of convertto-json is 2, which is often too low.

function pjson ($jsonfile) {
  (get-content $jsonfile) | convertfrom-json | convertto-json -depth 100 | 
    set-content $jsonfile
}

Leave a Comment