ConvertFrom-JSON to object


It looks like the way I am expecting this to work doesn’t. I want multiple objects returned, but it seems to be returning just one. It is beyond me how I do it.

A very simple JSON file:

I want to dynamically add the parameters and their values into a nice pscustomobject (that would look like the following with the above data):

What I don’t understand is why the following returns one object:

Whilst writing this, I eventually found a solution that get’s what I want, which I’ll post in the answer section. Feel free to school me and improve…


I would do things a little differently, skipping the hashtable, and using the hidden PSObject property. So, picking up after you have the JSON data stored in $content, I would do something like this:

By the way, it had issues converting the JSON you posted, I had to add quotes around the two values, such as "value": "sa01".


ConvertFrom-JSON to object by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply