Extract value from JSON

前端 未结 2 1739
天涯浪人
天涯浪人 2021-01-05 17:19

I am trying to use PowerShell to extract value from JSON object, I have the following JSON:

{
    \"$schema\": \"http://schema.management.azure.com/schemas/2         


        
相关标签:
2条回答
  • 2021-01-05 18:10

    I don't know why, but the approach from message above don't work for me. But works just getting key that you need by key after "ConvertFrom-Json" command, e.g.:

    $yourVariable = (Get-Content 'yourJsonFilePath.json' | ConvertFrom-Json).clusterStorageAccountName
    
    0 讨论(0)
  • 2021-01-05 18:14

    Use the Get-Content cmdlet to read the file, convert it using the ConvertFrom-Json cmdlet and just access the property you want:

    $yourVariable = (Get-Content 'yourJsonFilePath.json' | ConvertFrom-Json).parameters.clusterStorageAccountName.value
    
    0 讨论(0)
提交回复
热议问题