jeudi 30 septembre 2021

PowerShell iterate through json of key value pairs

I have a json file that maps alpha-2 codes to country names:

{
    "AF": "Afghanistan",
    "EG": "Ägypten",
    ...
}

I want to iterate over each key value pair to process the data. How would I be able to achieve that?

I tried the following but it always returns one big object that is not iterable in a key value manner:

$json = Get-Content -Path C:\countries.json | ConvertFrom-Json




Aucun commentaire:

Enregistrer un commentaire