How to round-trip this JSON to PSObject and back in Powershell

前端 未结 1 1475
南笙
南笙 2021-01-11 16:09

Powershell can\'t seem to correctly round-trip this JSON object:

{
    \"settings\": {
        \"minimumApproverCount\": 2,
        \"creatorVoteCounts\": fa         


        
1条回答
  •  被撕碎了的回忆
    2021-01-11 17:09

    Use the parameter Depth with value 3 or larger. The default 2 is not enough, deeper data are simply converted to strings.

    $json | ConvertFrom-Json | ConvertTo-Json -Depth 3
    

    Output

    {
        "settings":  {
                         "minimumApproverCount":  2,
                         "creatorVoteCounts":  false,
                         "scope":  [
                                       {
                                           "refName":  "refs/heads/d14rel",
                                           "matchKind":  "Exact",
                                           "repositoryId":  "a290117c-5a8a-40f7-bc2c-f14dbe3acf6d"
                                       }
                                   ]
                     }
    }
    

    0 讨论(0)
提交回复
热议问题