Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Test for JSON member presence or absence.

$
0
0

I have code that creates a PSCustomObject via ConvertFrom-Json like:

    $jsonResponse = $webStreamReader.ReadToEnd() | ConvertFrom-Json

In some cases the JSON object will contain a field 'error' and other times it will contain a field named 'odata.error'. How do I test for the existence of these two fields in the PSCustomObject.

Thank you.


Kevin Burton


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>