powershell 對json操作命令

讀取json文檔

$json = (Get-Content "C:\HDDList.json" -Raw) | ConvertFrom-Json
$select=$json.Content.selected[0]
$HddCoun=$json.Content.normal.Count

 

遍歷數組

foreach($str in $json.versions) { 
    echo "value: $str" 
} 

 

json數據轉換psobject.properties  

$json = (Get-Content "C:\nowSelect.json" -Raw) | ConvertFrom-Json

$select=$json.Content.selected[0].psobject.properties.Name						

$selectValue=$json.Content.selected[0].psobject.properties.Value

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章