# Parsing JSON w/ PS

**URL:** <https://forums.powershell.org/t/parsing-json-w-ps/11336>\
**Category:** PowerShell Help\
**Created:** [September 19, 2018, 6:20pm UTC](https://forums.powershell.org/t/parsing-json-w-ps/11336 "2018-09-19T18:20:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luksi1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@luksi1](https://forums.powershell.org/u/luksi1)\
**Post date:** [September 19, 2018, 6:20pm UTC](https://forums.powershell.org/t/parsing-json-w-ps/11336/1 "2018-09-19T18:20:09Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![ta11ow](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ta11ow/32/131_2.png) [@ta11ow](https://forums.powershell.org/u/ta11ow)\
**Post date:** [September 19, 2018, 7:01pm UTC](https://forums.powershell.org/t/parsing-json-w-ps/11336/2 "2018-09-19T19:01:45Z")

</div>

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
            }
        }
    }
```

---

<div class="post-metadata">

**Author:** ![sameermpm](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/sameermpm/32/289_2.png) [@sameermpm](https://forums.powershell.org/u/sameermpm)\
**Post date:** [September 20, 2018, 12:50am UTC](https://forums.powershell.org/t/parsing-json-w-ps/11336/3 "2018-09-20T00:50:00Z")

</div>

test

```
get-command
```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:34pm UTC](https://forums.powershell.org/t/parsing-json-w-ps/11336/4 "2024-05-16T20:34:22Z")

</div>

Closed on May 16, 2024, 8:34pm UTC


