Author Posts

January 10, 2017 at 7:13 pm

I'm getting results of a query from a TFS Api call that comes to the Shell in JSON format. Powershell then puts those results in a PScustomObject. I normally take those results and use them to perform an update to the service hosting the Json payload. The problem I sometimes have is that the resulting object is rather deep in terms of a nested JSon / object structure. Which leads me to my question.

Tfs item I'm working with: https://www.visualstudio.com/en-us/docs/integrate/api/rm/definitions

If I have a custom Object [pscustomobject] how can it tell what the deepest depth is so I can send that result to Invoke-webrequest -depth (deepest)

January 14, 2017 at 7:01 pm

You really can't. .NET doesn't see this as "depth," per se; it's an object, with properties, some of which are actually collections of other objects. Until you recurse the entire thing, you can't know how far it goes. .NET just doesn't conceptualize objects that way.

January 18, 2017 at 8:47 pm

It's interesting that you don't have this Depth option on importing json but exporting you do.. Why is that?
(gcm convertfrom-json ).parameters.keys
InputObject
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable