Prettifying JSON with PowerShell
A quick and dirty way to quickly prettifying JSON-files with PowerShell.
The problem
I had several files with compressed JSON, like this:
Not very readable. With Visual Studio, and other tools, you could easily to this more human friendly. But I had several files I wanted to do this with, so I went to PowerShell.
Solution
This little script gets the work done:
As you see there is some special treatments for the characters <, > and ‘. PowerShell want to do some special encoding for these characters. In most cases this is not necessary so I simple replace them.
Executing this on the sample file above changes it to this:
Much better!
Summary
I do think other tools to a better job, PowerShell intend the lines with many spaces. But I needed this just to make it easier to compare JSON-files, and then I thought that this was good enough.