# Evaluating json array objects. Please assist

**URL:** <https://forums.powershell.org/t/evaluating-json-array-objects-please-assist/12934>\
**Category:** PowerShell Help\
**Created:** [July 29, 2019, 11:34pm UTC](https://forums.powershell.org/t/evaluating-json-array-objects-please-assist/12934 "2019-07-29T23:34:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stan-gor](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@stan-gor](https://forums.powershell.org/u/stan-gor)\
**Post date:** [July 29, 2019, 11:34pm UTC](https://forums.powershell.org/t/evaluating-json-array-objects-please-assist/12934/1 "2019-07-29T23:34:55Z")

</div>

I need to evaluate if current month and day is true based on start and end in each array object and if it is then print the cns value. Thank you for your help!

#json file

[pre]

{

 "times": [{ "start": "01/01", "end": "03/01", "cns": "8" }, { "start": "04/01", "end": "07/01", "cns": "6" }]

}
[/pre]

&nbsp;

---

<div class="post-metadata">

**Author:** ![rejikodiyil](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@rejikodiyil](https://forums.powershell.org/u/rejikodiyil)\
**Post date:** [July 30, 2019, 4:08am UTC](https://forums.powershell.org/t/evaluating-json-array-objects-please-assist/12934/2 "2019-07-30T04:08:18Z")

</div>

Hi, I don’t know how you are going to read this. Assuming, you are reading it from a file.

[pre]  
$x = Get-Content C:\Temp\json.txt | ConvertFrom-Json  
PS M:&gt; $x.times

start end cns

* * *

01/01 03/01 8  
04/01 07/01 6

[/pre]

After the ‘ConvertFrom-Json’ command, you will get a PSCustomObject and you can iterate through each item.

---

<div class="post-metadata">

**Author:** ![stan-gor](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@stan-gor](https://forums.powershell.org/u/stan-gor)\
**Post date:** [July 30, 2019, 10:27am UTC](https://forums.powershell.org/t/evaluating-json-array-objects-please-assist/12934/3 "2019-07-30T10:27:39Z")

</div>

Thank you for your reply! How to iterate through each item?

Thanks!

&nbsp;

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 30, 2019, 7:58pm UTC](https://forums.powershell.org/t/evaluating-json-array-objects-please-assist/12934/4 "2019-07-30T19:58:49Z")

</div>

Please start with learning the very basics of Powershell. It’s beyond the scope of any forum to teach you the fundamentals of any technology. You will have to learn that first.

You can use [Foreach-Object](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-5.1) or [about\_foreach](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-5.1).

---

<div class="post-metadata">

**Author:** ![stan-gor](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@stan-gor](https://forums.powershell.org/u/stan-gor)\
**Post date:** [July 30, 2019, 9:33pm UTC](https://forums.powershell.org/t/evaluating-json-array-objects-please-assist/12934/5 "2019-07-30T21:33:13Z")

</div>

Understand. Thank you for your time!

---

<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:31pm UTC](https://forums.powershell.org/t/evaluating-json-array-objects-please-assist/12934/6 "2024-05-16T20:31:53Z")

</div>

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


