Parsing JSON w/ PS

I think this code looks convoluted and messy… and I like clean code :slight_smile: My question, to paraphrase one of my favorite films is: “is this as good as it gets?”

https://gist.github.com/luksi1/366759b14cc50193d5fdb6d9ed56a571

There are a few ways to write it, but with an object structured in that fashion, that’s about it. A more pipelined version might be something like this:

$Json | ConvertFrom-Json |
    ForEach-Object {
        foreach ($Name in $_.Value.PSObject.Properties.Name) {
            [PSCustomObject]@{
                Name = $Name
                Days_Remaining = $_.$Name.Days_Remaining
            }
        }
    }

test

get-command