PScustom Object depth

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Thom Schumacher Thom Schumacher 3 days, 1 hour ago.

  • Author
    Posts
  • #61662
    Profile photo of Thom Schumacher
    Thom Schumacher
    Participant

    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)

  • #61951
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.

  • #62100
    Profile photo of Thom Schumacher
    Thom Schumacher
    Participant

    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

You must be logged in to reply to this topic.